pub struct UnsafeStorage<T>(/* private fields */);
Expand description
UnsafeStorage
is used to mark that there are some arbitrary invariants
which must be maintained in storing its inner value. Therefore, creation and
modifying of the inner value is an “unsafe” behavior. Although it might not
be unsafe in traditional Rust terms (no memory unsafety), behavior might be
“undefined”—or at least undocumented, because invariants are expected to be
upheld.
This is useful in macros which do not encapsulate their storage in modules. This makes the macros for the end-user more ergonomic, as they can use the macro multiple times in a single module.
Implementations§
Source§impl<T> UnsafeStorage<T>
impl<T> UnsafeStorage<T>
Sourcepub const unsafe fn new_unsafe(inner: T) -> Self
pub const unsafe fn new_unsafe(inner: T) -> Self
Create a new UnsafeStorage
with the given inner value.
§Safety
- See the broader scope that this is called in and which invariants are mentioned
Sourcepub unsafe fn as_ref_mut(&mut self) -> &mut T
pub unsafe fn as_ref_mut(&mut self) -> &mut T
Mutably access the value stored inside
§Safety
This should be a safe operation assuming that when modifying T to T’,
UnsafeStorage::new_unsafe
(T’) is safe
Trait Implementations§
Source§impl<T> AsRef<T> for UnsafeStorage<T>
impl<T> AsRef<T> for UnsafeStorage<T>
Source§impl<T: Clone> Clone for UnsafeStorage<T>
impl<T: Clone> Clone for UnsafeStorage<T>
Source§fn clone(&self) -> UnsafeStorage<T>
fn clone(&self) -> UnsafeStorage<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more