[−][src]Trait zc::Guarded
Requirement for a Dependant
type with the guarantee it will protect its
internal state.
Implementation
Guarded
is auto-implemented for types that implement NoInteriorMut
.
NoInteriorMut
is auto-implemented through #[derive(Dependant)]
. If the
auto-implementation fails you can disable it as shown below with
#[zc(unguarded)]
. You may alternatively use #[derive(NoInteriorMut)]
for
types that are used internally by a Dependant
.
use zc::Dependant; #[derive(Dependant)] // Disable the impl of `NoInteriorMut` #[zc(unguarded)] struct MyStruct<'a>(&'a ()); // Manually implementing `NoInteriorMut` unsafe impl<'a> zc::NoInteriorMut for MyStruct<'a> {}
Safety
If a type does not and/or can not implement NoInteriorMut
this trait can
be manually implemented provided the guarantee the type:
- Can safely be stored with it's lifetime erased (ie. as
'static
). - Does not provided an interface that will accept data with non-
'static
lifetime though a interior mutable interface.
Implementors
impl<T> Guarded for T where
T: NoInteriorMut,
[src]
T: NoInteriorMut,