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 unsafe fn new_unsafe(inner: T) -> Self
pub unsafe fn new_unsafe(inner: T) -> Self
§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
§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: Clone> Clone for UnsafeStorage<T>
impl<T: Clone> Clone for UnsafeStorage<T>
Source§fn clone(&self) -> UnsafeStorage<T>
fn clone(&self) -> UnsafeStorage<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Default> Default for UnsafeStorage<T>
impl<T: Default> Default for UnsafeStorage<T>
Source§fn default() -> UnsafeStorage<T>
fn default() -> UnsafeStorage<T>
Returns the “default value” for a type. Read more
Source§impl<T> Deref for UnsafeStorage<T>
impl<T> Deref for UnsafeStorage<T>
Source§impl<T: Hash> Hash for UnsafeStorage<T>
impl<T: Hash> Hash for UnsafeStorage<T>
Source§impl<T: Ord> Ord for UnsafeStorage<T>
impl<T: Ord> Ord for UnsafeStorage<T>
Source§fn cmp(&self, other: &UnsafeStorage<T>) -> Ordering
fn cmp(&self, other: &UnsafeStorage<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq> PartialEq for UnsafeStorage<T>
impl<T: PartialEq> PartialEq for UnsafeStorage<T>
Source§impl<T: PartialOrd> PartialOrd for UnsafeStorage<T>
impl<T: PartialOrd> PartialOrd for UnsafeStorage<T>
impl<T: Copy> Copy for UnsafeStorage<T>
impl<T: Eq> Eq for UnsafeStorage<T>
impl<T> StructuralPartialEq for UnsafeStorage<T>
Auto Trait Implementations§
impl<T> Freeze for UnsafeStorage<T>where
T: Freeze,
impl<T> RefUnwindSafe for UnsafeStorage<T>where
T: RefUnwindSafe,
impl<T> Send for UnsafeStorage<T>where
T: Send,
impl<T> Sync for UnsafeStorage<T>where
T: Sync,
impl<T> Unpin for UnsafeStorage<T>where
T: Unpin,
impl<T> UnwindSafe for UnsafeStorage<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more