[−][src]Trait string::StableAsRef
Marker trait that indicates that a type is guaranteed safe to use as backing storage
for String
.
In order to be safe, a storage type T
needs to guarantee the following:
-
If
T
implementsAsRef<[u8]>
and/orAsMut<[u8]>
, the contents ofT
as visible the byte slice returned byas_ref
andas_mut
may only be mutated through mutable references or owned access. In other words, no use of interior mutability. -
If
T
implementsAsRef<[u8]>
, theas_ref
method must always return the same slice of bytes (unless the storage is mutated). -
If
T
implementsAsRef<[u8]>
andAsMut<[u8]>
, theas_mut
method must return a mutable reference to the same slice of bytes as theas_ref
method returns. -
If
T
implementsAsRef<[u8]>
andDefault
, the default value must represent the empty byte sequence. In other words,T::default().as_ref().len() == 0
. -
If
T
implementsAsRef<[u8]>
andFrom<&[u8]>
, it must do so in such a way that the byte slice returned byas_ref
is equal to the byte slice provided to thefrom
method.
Implementations on Foreign Types
impl<'a, T> StableAsRef for &'a T where
T: StableAsRef,
[src]
T: StableAsRef,
impl<'a, T> StableAsRef for &'a mut T where
T: StableAsRef,
[src]
T: StableAsRef,
impl<T> StableAsRef for Box<T> where
T: StableAsRef,
[src]
T: StableAsRef,
impl<T> StableAsRef for Rc<T> where
T: StableAsRef,
[src]
T: StableAsRef,
impl<T> StableAsRef for Arc<T> where
T: StableAsRef,
[src]
T: StableAsRef,