Skip to main content

NonMax

Struct NonMax 

Source
pub struct NonMax<T: NonMaxItem>(/* private fields */);
Expand description

A wrapper type for an integer that cannot be its maximum value.

This type leverages Rust’s NonZero optimization by mapping the maximum value to zero internally. As a result, Option<NonMax<T>> has the same size as the underlying primitive type T.

§Examples

assert_eq!(size_of::<NonMaxU32>(), 4);
assert_eq!(size_of::<Option<NonMaxU32>>(), 4);

Implementations§

Source§

impl<T: NonMaxItem + Copy> NonMax<T>

Source

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

Creates a new NonMax if the given value is not the maximum value.

§Examples
assert!(NonMaxU8::new(254).is_some());
assert!(NonMaxU8::new(255).is_none());
Source

pub fn get(&self) -> T

Returns the underlying primitive value.

§Examples
let x = NonMaxU32::new(123).unwrap();
assert_eq!(x.get(), 123);
Source§

impl<T: NonMaxItem + Copy + PartialEq> NonMax<T>

Source

pub fn is_min(&self) -> bool

Returns true if this is the minimum value.

Source

pub fn is_max(&self) -> bool

Returns true if this is the maximum possible value for this type.

Source

pub fn is_zero(&self) -> bool

Returns true if the value is zero.

Source§

impl<T: NonMaxItem + Copy> NonMax<T>

Source

pub fn checked_add(self, rhs: Self) -> Option<Self>

Checked integer addition. Computes self + rhs, returning None if overflow occurred or if the result is the maximum value.

Source

pub fn checked_sub(self, rhs: Self) -> Option<Self>

Checked integer subtraction. Computes self - rhs, returning None if overflow occurred or if the result is the maximum value.

Source

pub fn checked_mul(self, rhs: Self) -> Option<Self>

Checked integer multiplication. Computes self * rhs, returning None if overflow occurred or if the result is the maximum value.

Source

pub fn checked_div(self, rhs: Self) -> Option<Self>

Checked integer division. Computes self / rhs, returning None if the divisor is zero or if the result is the maximum value.

Source

pub fn checked_rem(self, rhs: Self) -> Option<Self>

Checked integer remainder. Computes self % rhs, returning None if the divisor is zero or if the result is the maximum value.

Source

pub fn checked_add_val(self, rhs: T) -> Option<Self>

Checked addition with a primitive value.

§Examples
let x = NonMaxU8::new(100).unwrap();
assert_eq!(x.checked_add_val(50).unwrap().get(), 150);
assert!(x.checked_add_val(155).is_none()); // 255 is MAX
Source

pub fn checked_sub_val(self, rhs: T) -> Option<Self>

Checked subtraction with a primitive value.

Source

pub fn checked_mul_val(self, rhs: T) -> Option<Self>

Checked multiplication with a primitive value.

Source

pub fn checked_div_val(self, rhs: T) -> Option<Self>

Checked division with a primitive value.

Source

pub fn checked_rem_val(self, rhs: T) -> Option<Self>

Checked remainder with a primitive value.

Source§

impl NonMax<u8>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<u16>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<u32>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<u64>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<u128>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<usize>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<i8>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<i16>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<i32>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<i64>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<i128>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Source§

impl NonMax<isize>

Source

pub const MIN: Self

The minimum value for this type.

Source

pub const MAX: Self

The maximum value for this type.

Source

pub const ZERO: Self

The zero value for this type.

Source

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

Creates a new NonMax without checking the value.

§Safety

The value must not be the maximum value of the underlying type.

Trait Implementations§

Source§

impl<T: NonMaxItem + Copy + Add<Output = T>> Add<T> for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: NonMaxItem + Copy + Add<Output = T>> Add for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: NonMaxItem + Copy + Add<Output = T>> AddAssign<T> for NonMax<T>

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<T: NonMaxItem + Copy + Add<Output = T>> AddAssign for NonMax<T>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: NonMaxItem + Copy + Binary> Binary for NonMax<T>

Source§

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

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

impl<T: Clone + NonMaxItem> Clone for NonMax<T>
where T::NonZero: Clone,

Source§

fn clone(&self) -> NonMax<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 + NonMaxItem> Debug for NonMax<T>
where T::NonZero: Debug,

Source§

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

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

impl<T: NonMaxItem + Copy> Default for NonMax<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: NonMaxItem + Copy + Display> Display for NonMax<T>

Source§

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

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

impl<T: NonMaxItem + Copy + Div<T, Output = T>> Div<T> for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: NonMaxItem + Copy + Div<Output = T>> Div for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: NonMaxItem + Copy + Div<T, Output = T>> DivAssign<T> for NonMax<T>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T: NonMaxItem + Copy + Div<Output = T>> DivAssign for NonMax<T>

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl From<NonMax<i128>> for i128

Source§

fn from(value: NonMax<i128>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<i16>> for i16

Source§

fn from(value: NonMax<i16>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<i32>> for i32

Source§

fn from(value: NonMax<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<i64>> for i64

Source§

fn from(value: NonMax<i64>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<i8>> for i8

Source§

fn from(value: NonMax<i8>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<isize>> for isize

Source§

fn from(value: NonMax<isize>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<u128>> for u128

Source§

fn from(value: NonMax<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<u16>> for u16

Source§

fn from(value: NonMax<u16>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<u32>> for u32

Source§

fn from(value: NonMax<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<u64>> for u64

Source§

fn from(value: NonMax<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<u8>> for u8

Source§

fn from(value: NonMax<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<NonMax<usize>> for usize

Source§

fn from(value: NonMax<usize>) -> Self

Converts to this type from the input type.
Source§

impl FromStr for NonMax<i128>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<i16>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<i32>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<i64>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<i8>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<isize>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<u128>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<u16>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<u32>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<u64>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<u8>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for NonMax<usize>

Source§

type Err = ParseNonMaxError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<T: Hash + NonMaxItem> Hash for NonMax<T>
where T::NonZero: Hash,

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<T> Index<NonMax<usize>> for [T]

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: NonMaxUsize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> Index<NonMax<usize>> for Vec<T>

Available on crate feature alloc only.
Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: NonMaxUsize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<NonMax<usize>> for [T]

Source§

fn index_mut(&mut self, index: NonMaxUsize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<NonMax<usize>> for Vec<T>

Available on crate feature alloc only.
Source§

fn index_mut(&mut self, index: NonMaxUsize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: NonMaxItem + Copy + LowerHex> LowerHex for NonMax<T>

Source§

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

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

impl<T: NonMaxItem + Copy + Mul<Output = T>> Mul<T> for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: NonMaxItem + Copy + Mul<Output = T>> Mul for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: NonMaxItem + Copy + Mul<Output = T>> MulAssign<T> for NonMax<T>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: NonMaxItem + Copy + Mul<Output = T>> MulAssign for NonMax<T>

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<T: NonMaxItem + Copy + Octal> Octal for NonMax<T>

Source§

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

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

impl<T: NonMaxItem + Copy + Ord> Ord for NonMax<T>

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

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

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

impl<T: PartialEq + NonMaxItem> PartialEq for NonMax<T>
where T::NonZero: PartialEq,

Source§

fn eq(&self, other: &NonMax<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: NonMaxItem + Copy + PartialOrd> PartialOrd for NonMax<T>

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 · 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 · 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 · 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 · 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<'a, T: NonMaxItem + Copy + Mul<Output = T>> Product<&'a NonMax<T>> for NonMax<T>

Source§

fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<T: NonMaxItem + Copy + Mul<Output = T>> Product for NonMax<T>

Source§

fn product<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<T: NonMaxItem + Copy + Rem<T, Output = T>> Rem<T> for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl<T: NonMaxItem + Copy + Rem<Output = T>> Rem for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl<T: NonMaxItem + Copy + Rem<T, Output = T>> RemAssign<T> for NonMax<T>

Source§

fn rem_assign(&mut self, rhs: T)

Performs the %= operation. Read more
Source§

impl<T: NonMaxItem + Copy + Rem<Output = T>> RemAssign for NonMax<T>

Source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
Source§

impl<T: NonMaxItem + Copy + Sub<Output = T>> Sub<T> for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: NonMaxItem + Copy + Sub<Output = T>> Sub for NonMax<T>

Source§

type Output = NonMax<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: NonMaxItem + Copy + Sub<Output = T>> SubAssign<T> for NonMax<T>

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl<T: NonMaxItem + Copy + Sub<Output = T>> SubAssign for NonMax<T>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<'a, T: NonMaxItem + Copy + Add<Output = T>> Sum<&'a NonMax<T>> for NonMax<T>

Source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T: NonMaxItem + Copy + Add<Output = T>> Sum for NonMax<T>

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl TryFrom<i128> for NonMax<i128>

Source§

type Error = MaxValueError

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 TryFrom<i16> for NonMax<i16>

Source§

type Error = MaxValueError

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 TryFrom<i32> for NonMax<i32>

Source§

type Error = MaxValueError

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 TryFrom<i64> for NonMax<i64>

Source§

type Error = MaxValueError

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 TryFrom<i8> for NonMax<i8>

Source§

type Error = MaxValueError

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 TryFrom<isize> for NonMax<isize>

Source§

type Error = MaxValueError

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 TryFrom<u128> for NonMax<u128>

Source§

type Error = MaxValueError

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 TryFrom<u16> for NonMax<u16>

Source§

type Error = MaxValueError

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 TryFrom<u32> for NonMax<u32>

Source§

type Error = MaxValueError

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 TryFrom<u64> for NonMax<u64>

Source§

type Error = MaxValueError

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 TryFrom<u8> for NonMax<u8>

Source§

type Error = MaxValueError

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 TryFrom<usize> for NonMax<usize>

Source§

type Error = MaxValueError

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<T: NonMaxItem + Copy + UpperHex> UpperHex for NonMax<T>

Source§

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

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

impl<T: Copy + NonMaxItem> Copy for NonMax<T>
where T::NonZero: Copy,

Source§

impl<T: Eq + NonMaxItem> Eq for NonMax<T>
where T::NonZero: Eq,

Source§

impl<T: NonMaxItem> StructuralPartialEq for NonMax<T>

Auto Trait Implementations§

§

impl<T> Freeze for NonMax<T>
where <T as NonMaxItem>::NonZero: Freeze,

§

impl<T> RefUnwindSafe for NonMax<T>
where <T as NonMaxItem>::NonZero: RefUnwindSafe,

§

impl<T> Send for NonMax<T>
where <T as NonMaxItem>::NonZero: Send,

§

impl<T> Sync for NonMax<T>
where <T as NonMaxItem>::NonZero: Sync,

§

impl<T> Unpin for NonMax<T>
where <T as NonMaxItem>::NonZero: Unpin,

§

impl<T> UnwindSafe for NonMax<T>
where <T as NonMaxItem>::NonZero: 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.