Struct rust_examples::brands::InvariantLifetime [−][src]
pub struct InvariantLifetime<'id>(_);Expand description
Lifetime wrapper which makes 'id invariant and has no size.
The invariance of 'id (resp. InvariantLifetime) comes from the underlying raw pointer type
*mut &'id () - see the docs.
Zero size is achieved via the usage of opaque type PhantomData which only carries the type information until the compilation and then is “compiled away”.
Note that the invariance of 'id (resp. InvariantLifetime) means that one cannot change
the brand ('id) of BrandedIndex or BrandedVec via
subtyping.
Example: Size Test
use rust_examples::brands::InvariantLifetime;
assert_eq!(std::mem::size_of::<InvariantLifetime<'_>>(), std::mem::size_of::<()>());Trait Implementations
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl<'id> RefUnwindSafe for InvariantLifetime<'id>
impl<'id> !Send for InvariantLifetime<'id>
impl<'id> !Sync for InvariantLifetime<'id>
impl<'id> Unpin for InvariantLifetime<'id>
impl<'id> UnwindSafe for InvariantLifetime<'id>
Blanket Implementations
Mutably borrows from an owned value. Read more
