[−][src]Trait zc::Dependant
Implemented for Guarded
types that use data provided by an Owner
.
Derive implementations (recommended)
It is recommeneded not to implement this manually and instead use the provided proc-macro as show below.
use zc::Dependant; #[derive(Dependant)] pub struct MyStruct<'a> { value: &'a str, }
Manual implementations
If you wish not to use the provided proc-macro you implement as shown:
use zc::Guarded; #[derive(Guarded)] struct MyStruct<'a>(&'a [u8]); unsafe impl<'a> zc::Dependant<'a> for MyStruct<'a> { type Static = MyStruct<'static>; unsafe fn erase_lifetime(self) -> Self::Static { core::mem::transmute(self) } }
Safety
Implementer must guarantee:
- The structure only requires a single lifetime.
Self::Static
must be the same type but with a'static
lifetime.
Associated Types
type Static: Dependant<'static> + 'static
[src]
Always the exact same structure as Self
but instead with a 'static
lifetime.
Required methods
pub unsafe fn erase_lifetime(self) -> Self::Static
[src]
Erases the Dependant
's lifetime by returning a static variant.
Safety
The value returned is for use by the Zc
structure only.