Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deptypes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ default = ["std"]
std = []
never = []
trusted_len = []
nightly = ["never", "trusted_len"]
super_let = []
nightly = ["never", "trusted_len", "super_let"]
20 changes: 20 additions & 0 deletions deptypes/src/guard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pub use generativity::*;

#[cfg(feature = "super_let")]
#[cfg_attr(docsrs, doc(cfg(feature = "super_let")))]
#[macro_export]
/// Create and return a [`generativity::Guard`] with a unique brand.
///
/// This macro mirrors [`make_guard!`] but produces the guard directly instead
/// of binding it to a user-provided identifier. Because it relies on the
/// unstable `super_let` language feature, it is only available when the
/// crate's `"super_let"` feature is enabled (or through the `"nightly"`
/// feature, which enables `"super_let"`).
macro_rules! guard {
() => {{
super let branded_place = unsafe { $crate::guard::Id::new() };
#[allow(unused)]
let lifetime_brand = unsafe { $crate::guard::LifetimeBrand::new(&branded_place) };
unsafe { $crate::guard::Guard::new(branded_place) }
}};
}
11 changes: 9 additions & 2 deletions deptypes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#![cfg_attr(feature = "never", feature(never_type))]
#![cfg_attr(feature = "trusted_len", feature(trusted_len))]
#![cfg_attr(feature = "super_let", feature(super_let))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(feature = "std")]
extern crate alloc;
Expand All @@ -17,8 +19,13 @@ pub mod newtype;
#[macro_use]
pub mod zst;

pub use generativity as guard;
pub use generativity::make_guard as make_guard;
pub mod guard;
pub use crate::guard::make_guard as make_guard;

#[cfg(feature = "super_let")]
#[cfg_attr(docsrs, doc(cfg(feature = "super_let")))]
#[doc(inline)]
pub use crate::guard::guard as g;

#[macro_use]
pub mod type_eq;
Expand Down