ShouldNotBeZero

Struct ShouldNotBeZero 

Source
pub struct ShouldNotBeZero<T>(/* private fields */)
where
    T: ZeroableThing;
Expand description

Describes something that is valid when passed as a zero but SHOULDN’T BE a zero

mainly for usage with FFI and OptZero so that if it was passed as a zero it would be treated as a None value

Implementations§

Source§

impl<T> ShouldNotBeZero<T>
where T: ZeroableThing,

Source

pub fn new(value: T) -> Option<ShouldNotBeZero<T>>

Source

pub const unsafe fn new_unchecked(value: T) -> ShouldNotBeZero<T>

Source

pub const fn value_ref(&self) -> &T

Source§

impl<T> ShouldNotBeZero<T>
where T: ZeroableThing + Copy,

Source

pub const fn value(&self) -> T

Trait Implementations§

Source§

impl<T> Clone for ShouldNotBeZero<T>
where T: Clone + ZeroableThing,

Source§

fn clone(&self) -> ShouldNotBeZero<T>

Returns a duplicate 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<T> Debug for ShouldNotBeZero<T>
where T: Debug + ZeroableThing,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<NonZero<i128>> for ShouldNotBeZero<i128>

Source§

fn from(value: NonZero<i128>) -> ShouldNotBeZero<i128>

Converts to this type from the input type.
Source§

impl From<NonZero<i16>> for ShouldNotBeZero<i16>

Source§

fn from(value: NonZero<i16>) -> ShouldNotBeZero<i16>

Converts to this type from the input type.
Source§

impl From<NonZero<i32>> for ShouldNotBeZero<i32>

Source§

fn from(value: NonZero<i32>) -> ShouldNotBeZero<i32>

Converts to this type from the input type.
Source§

impl From<NonZero<i64>> for ShouldNotBeZero<i64>

Source§

fn from(value: NonZero<i64>) -> ShouldNotBeZero<i64>

Converts to this type from the input type.
Source§

impl From<NonZero<i8>> for ShouldNotBeZero<i8>

Source§

fn from(value: NonZero<i8>) -> ShouldNotBeZero<i8>

Converts to this type from the input type.
Source§

impl From<NonZero<isize>> for ShouldNotBeZero<isize>

Source§

fn from(value: NonZero<isize>) -> ShouldNotBeZero<isize>

Converts to this type from the input type.
Source§

impl From<NonZero<u128>> for ShouldNotBeZero<u128>

Source§

fn from(value: NonZero<u128>) -> ShouldNotBeZero<u128>

Converts to this type from the input type.
Source§

impl From<NonZero<u16>> for ShouldNotBeZero<u16>

Source§

fn from(value: NonZero<u16>) -> ShouldNotBeZero<u16>

Converts to this type from the input type.
Source§

impl From<NonZero<u32>> for ShouldNotBeZero<u32>

Source§

fn from(value: NonZero<u32>) -> ShouldNotBeZero<u32>

Converts to this type from the input type.
Source§

impl From<NonZero<u64>> for ShouldNotBeZero<u64>

Source§

fn from(value: NonZero<u64>) -> ShouldNotBeZero<u64>

Converts to this type from the input type.
Source§

impl From<NonZero<u8>> for ShouldNotBeZero<u8>

Source§

fn from(value: NonZero<u8>) -> ShouldNotBeZero<u8>

Converts to this type from the input type.
Source§

impl From<NonZero<usize>> for ShouldNotBeZero<usize>

Source§

fn from(value: NonZero<usize>) -> ShouldNotBeZero<usize>

Converts to this type from the input type.
Source§

impl<T> Hash for ShouldNotBeZero<T>
where T: Hash + ZeroableThing,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> NotZeroable for ShouldNotBeZero<T>
where T: ZeroableThing,

Source§

fn is_zero(&self) -> bool

Source§

impl<T> PartialEq for ShouldNotBeZero<T>

Source§

fn eq(&self, other: &ShouldNotBeZero<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Copy for ShouldNotBeZero<T>
where T: Copy + ZeroableThing,

Source§

impl<T> Eq for ShouldNotBeZero<T>
where T: Eq + ZeroableThing,

Source§

impl<T> StructuralPartialEq for ShouldNotBeZero<T>
where T: ZeroableThing,

Auto Trait Implementations§

§

impl<T> Freeze for ShouldNotBeZero<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ShouldNotBeZero<T>
where T: RefUnwindSafe,

§

impl<T> Send for ShouldNotBeZero<T>
where T: Send,

§

impl<T> Sync for ShouldNotBeZero<T>
where T: Sync,

§

impl<T> Unpin for ShouldNotBeZero<T>
where T: Unpin,

§

impl<T> UnwindSafe for ShouldNotBeZero<T>
where T: UnwindSafe,

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.