Struct bit_struct::UnsafeStorage
source · [−]#[repr(transparent)]pub struct UnsafeStorage<T>(_);
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
sourceimpl<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
sourceimpl<T: Copy> UnsafeStorage<T>
impl<T: Copy> UnsafeStorage<T>
Trait Implementations
sourceimpl<T> AsRef<T> for UnsafeStorage<T>
impl<T> AsRef<T> for UnsafeStorage<T>
sourceimpl<T: Clone> Clone for UnsafeStorage<T>
impl<T: Clone> Clone for UnsafeStorage<T>
sourcefn clone(&self) -> UnsafeStorage<T>
fn clone(&self) -> UnsafeStorage<T>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl<T: Default> Default for UnsafeStorage<T>
impl<T: Default> Default for UnsafeStorage<T>
sourcefn default() -> UnsafeStorage<T>
fn default() -> UnsafeStorage<T>
sourceimpl<T: Hash> Hash for UnsafeStorage<T>
impl<T: Hash> Hash for UnsafeStorage<T>
sourceimpl<T: Ord> Ord for UnsafeStorage<T>
impl<T: Ord> Ord for UnsafeStorage<T>
sourcefn cmp(&self, other: &UnsafeStorage<T>) -> Ordering
fn cmp(&self, other: &UnsafeStorage<T>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl<T: PartialEq> PartialEq<UnsafeStorage<T>> for UnsafeStorage<T>
impl<T: PartialEq> PartialEq<UnsafeStorage<T>> for UnsafeStorage<T>
sourcefn eq(&self, other: &UnsafeStorage<T>) -> bool
fn eq(&self, other: &UnsafeStorage<T>) -> bool
sourceimpl<T: PartialOrd> PartialOrd<UnsafeStorage<T>> for UnsafeStorage<T>
impl<T: PartialOrd> PartialOrd<UnsafeStorage<T>> for UnsafeStorage<T>
sourcefn partial_cmp(&self, other: &UnsafeStorage<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &UnsafeStorage<T>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more