pub struct Unsafe<O: ?Sized, F: ?Sized, const NAME_HASH: u128> { /* private fields */ }
Expand description
A field with safety invariants.
Unsafe
should not be named directly - instead, use unsafe_fields!
to
declare a type with unsafe fields.
See the crate-level documentation for more information.
Implementations§
Source§impl<O: ?Sized, F: ?Sized, const NAME_HASH: u128> Unsafe<O, F, NAME_HASH>
impl<O: ?Sized, F: ?Sized, const NAME_HASH: u128> Unsafe<O, F, NAME_HASH>
Sourcepub const unsafe fn as_ref_unchecked(&self) -> &F
pub const unsafe fn as_ref_unchecked(&self) -> &F
Gets a reference to the inner value.
If F: Immutable
, prefer as_ref
, which is safe.
§Safety
The caller is responsible for upholding any safety invariants associated with this field.
Sourcepub const fn as_ref(&self) -> &Fwhere
F: Immutable,
Available on crate feature zerocopy_0_8
only.
pub const fn as_ref(&self) -> &Fwhere
F: Immutable,
zerocopy_0_8
only.Gets a reference to the inner value safely so long as the inner value is immutable.
If F: Immutable
, then F
does not permit interior
mutation, and so it is safe to return a reference to it.
Trait Implementations§
impl<O: ?Sized, F: Copy, const NAME_HASH: u128> Copy for Unsafe<O, F, NAME_HASH>
Auto Trait Implementations§
impl<O, F, const NAME_HASH: u128> Freeze for Unsafe<O, F, NAME_HASH>
impl<O, F, const NAME_HASH: u128> RefUnwindSafe for Unsafe<O, F, NAME_HASH>
impl<O, F, const NAME_HASH: u128> Send for Unsafe<O, F, NAME_HASH>
impl<O, F, const NAME_HASH: u128> Sync for Unsafe<O, F, NAME_HASH>
impl<O, F, const NAME_HASH: u128> Unpin for Unsafe<O, F, NAME_HASH>
impl<O, F, const NAME_HASH: u128> UnwindSafe for Unsafe<O, F, NAME_HASH>
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