Skip to main content

NonAnyI16

Struct NonAnyI16 

Source
pub struct NonAnyI16<const NICHE: i16>(/* private fields */);
Expand description

An integer that is known not to equal NICHE.

This enables some memory layout optimization. For example, Option<NonAnyI16<0>> is the same size as i16:

assert_eq!(core::mem::size_of::<Option<nonany::NonAnyI16<0>>>(), core::mem::size_of::<i16>());

Implementations§

Source§

impl<const NICHE: i16> NonAnyI16<NICHE>

Source

pub const NICHE: i16 = NICHE

The niche value of this integer type.

Source

pub const BITS: u32 = i16::BITS

The size of this integer type in bits.

Source

pub const fn new(value: i16) -> Option<Self>

Creates a non-any if the given value is not NICHE.

Source

pub const unsafe fn new_unchecked(value: i16) -> Self

Creates a non-any without checking whether the value is NICHE. This results in undefined behaviour if the value is NICHE.

§Safety

The value must not be NICHE.

Source

pub const fn get(self) -> i16

Returns the contained value as a primitive type.

Source

pub const fn abs(self) -> Option<Self>

Source

pub const fn checked_abs(self) -> Result<Self, CheckedError>

Source

pub const fn is_positive(self) -> bool

Source

pub const fn is_negative(self) -> bool

Trait Implementations§

Source§

impl<const NICHE: i16> Binary for NonAnyI16<NICHE>

Source§

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

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

impl<const NICHE: i16> Clone for NonAnyI16<NICHE>

Source§

fn clone(&self) -> NonAnyI16<NICHE>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const NICHE: i16> Debug for NonAnyI16<NICHE>

Source§

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

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

impl<const NICHE: i16> Display for NonAnyI16<NICHE>

Source§

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

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

impl<const NICHE: i16> Hash for NonAnyI16<NICHE>

Source§

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

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<const NICHE: i16> LowerExp for NonAnyI16<NICHE>

Source§

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

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

impl<const NICHE: i16> LowerHex for NonAnyI16<NICHE>

Source§

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

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

impl<const NICHE: i16> Octal for NonAnyI16<NICHE>

Source§

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

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

impl<const NICHE: i16> Ord for NonAnyI16<NICHE>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<const NICHE: i16> PartialEq for NonAnyI16<NICHE>

Source§

fn eq(&self, other: &NonAnyI16<NICHE>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<const NICHE: i16> PartialOrd for NonAnyI16<NICHE>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: i128> TryFrom<NonAnyI128<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI128<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i128, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyI128<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i32, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyI32<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i64, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyI64<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i8, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyI8<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: isize, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyIsize<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: u128, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyU128<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: u16, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyU16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: u32, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyU32<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: u64, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyU64<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: u8, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyU8<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: usize, const FROM_NICHE: i16> TryFrom<NonAnyI16<FROM_NICHE>> for NonAnyUsize<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: i32> TryFrom<NonAnyI32<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI32<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: i64> TryFrom<NonAnyI64<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI64<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: i8> TryFrom<NonAnyI8<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyI8<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: isize> TryFrom<NonAnyIsize<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyIsize<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: u128> TryFrom<NonAnyU128<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyU128<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: u16> TryFrom<NonAnyU16<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyU16<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: u32> TryFrom<NonAnyU32<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyU32<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: u64> TryFrom<NonAnyU64<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyU64<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: u8> TryFrom<NonAnyU8<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyU8<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const TO_NICHE: i16, const FROM_NICHE: usize> TryFrom<NonAnyUsize<FROM_NICHE>> for NonAnyI16<TO_NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonAnyUsize<FROM_NICHE>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<i128>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroI128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<i16>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroI16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<i32>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroI32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<i64>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroI64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<i8>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroI8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<isize>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroIsize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<u128>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroU128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<u16>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroU16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<u32>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroU32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<u64>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroU64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<u8>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroU8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<NonZero<usize>> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: NonZeroUsize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<i128> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: i128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<i16> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: i16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<i32> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: i32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<i64> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<i8> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: i8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<isize> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: isize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<u128> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<u16> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: u16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<u32> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<u64> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<u8> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> TryFrom<usize> for NonAnyI16<NICHE>

Source§

type Error = CheckedError

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

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const NICHE: i16> UpperExp for NonAnyI16<NICHE>

Source§

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

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

impl<const NICHE: i16> UpperHex for NonAnyI16<NICHE>

Source§

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

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

impl<const NICHE: i16> Copy for NonAnyI16<NICHE>

Source§

impl<const NICHE: i16> Eq for NonAnyI16<NICHE>

Source§

impl<const NICHE: i16> StructuralPartialEq for NonAnyI16<NICHE>

Auto Trait Implementations§

§

impl<const NICHE: i16> Freeze for NonAnyI16<NICHE>

§

impl<const NICHE: i16> RefUnwindSafe for NonAnyI16<NICHE>

§

impl<const NICHE: i16> Send for NonAnyI16<NICHE>

§

impl<const NICHE: i16> Sync for NonAnyI16<NICHE>

§

impl<const NICHE: i16> Unpin for NonAnyI16<NICHE>

§

impl<const NICHE: i16> UnsafeUnpin for NonAnyI16<NICHE>

§

impl<const NICHE: i16> UnwindSafe for NonAnyI16<NICHE>

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, 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.