Struct Unsafe

Source
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>

Source

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.

Source

pub const fn as_ref(&self) -> &F
where F: Immutable,

Available on crate feature 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.

Source

pub unsafe fn as_mut(&mut self) -> &mut F

Gets a mutable reference to the inner value.

§Safety

The caller is responsible for upholding any safety invariants associated with this field.

Source§

impl<O: ?Sized, F, const NAME_HASH: u128> Unsafe<O, F, NAME_HASH>

Source

pub const unsafe fn new(field: F) -> Unsafe<O, F, NAME_HASH>

Constructs a new Unsafe.

§Safety

The caller is responsible for upholding any safety invariants associated with this field.

Source

pub const fn into(self) -> F

Extracts the inner F from self.

Trait Implementations§

Source§

impl<O: ?Sized, F: Copy, const NAME_HASH: u128> Clone for Unsafe<O, F, NAME_HASH>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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>
where F: Freeze + ?Sized, O: ?Sized,

§

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>
where F: Send + ?Sized, O: Send + ?Sized,

§

impl<O, F, const NAME_HASH: u128> Sync for Unsafe<O, F, NAME_HASH>
where F: Sync + ?Sized, O: Sync + ?Sized,

§

impl<O, F, const NAME_HASH: u128> Unpin for Unsafe<O, F, NAME_HASH>
where F: Unpin + ?Sized, O: Unpin + ?Sized,

§

impl<O, F, const NAME_HASH: u128> UnwindSafe for Unsafe<O, F, NAME_HASH>
where F: UnwindSafe + ?Sized, O: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.