PositiveI64

Struct PositiveI64 

Source
#[repr(C, align(8))]
pub struct PositiveI64 { /* private fields */ }
Expand description

A signed value that is known to be positive.

This enables some memory layout optimization. For example, Option<PositiveI64> is the same size as i64.

Implementations§

Source§

impl PositiveI64

Source

pub const BITS: u32 = 64u32

The size of this positive integer type in bits.

This value is equal to i64::BITS.

Source

pub const MIN: Self

The smallest value that can be represented by this positive integer type, 0.

Source

pub const MAX: Self

The largest value that can be represented by this positive integer type, equal to i64::MAX.

Source

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

Creates a PositiveI64 if the given value is positive.

Source

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

Creates a PositiveI64 without checking whether the value is positive. This results in undefined behaviour if the value is negative.

§Safety

The value must not be negative.

Source

pub const fn get(self) -> i64

Returns the contained value as a primitive type.

Source

pub const fn count_zeros(self) -> u32

Returns the number of zeros in the binary representation of self.

Source

pub const fn count_ones(self) -> u32

Returns the number of ones in the binary representation of self.

Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation of self.

Source

pub const fn is_power_of_two(self) -> bool

Returns true if and only if self == (1 << k) for some k.

Source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

§Panics

This function will panic if self is zero.

Source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

§Panics

This function will panic if self is zero.

Source

pub const fn checked_neg(self) -> Option<NegativeI64>

Checked negation. Computes -self, returning None if self == 0.

Source

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

Checked addition. Adds a positive integer to another positive integer. Checks for overflow and returns None on overflow. As a consequence, the result cannot wrap to a negative integer.

Source

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

Checked subtraction. Subtracts a positive integer from another positive integer. Returns None if the result would overflow into a negative integer.

Source

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

Checked multiplication. Multiplies a positive integer by another positive integer, returning a positive result. Returns None if the result would overflow.

Source

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

Checked division. Divides a positive integer by another positive integer, returning the positive quotient. Returns None if rhs == 0.

Source

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

Checked remainder. Divides a positive integer by another positive integer, returning the positive remainder. Returns None if rhs == 0.

Source

pub const fn checked_div_unsigned(self, rhs: u64) -> Option<Self>

Checked division by unsigned. Divides a positive integer by an unsigned integer, returning the positive quotient. Returns None if rhs == 0.

Source

pub const fn checked_rem_unsigned(self, rhs: u64) -> Option<Self>

Checked remainder of unsigned. Divides a positive integer by an unsigned integer, returning the positive remainder. Returns None if rhs == 0.

Source

pub const fn checked_pow(self, rhs: u32) -> Option<Self>

Checked integer exponentiation. Raises positive value to an integer power. Checks for overflow and returns None on overflow. As a consequence, the result cannot wrap to a negative integer.

Source

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

Returns the smallest power of two greater than or equal to self. Checks for overflow and returns None if the next power of two is greater than the type’s maximum value. As a consequence, the result cannot wrap to a negative integer.

Source

pub const fn checked_ilog2(self) -> Option<u32>

Returns the base 2 logarithm of the number, rounded down.

Returns None if the number is zero.

Source

pub const fn checked_ilog10(self) -> Option<u32>

Returns the base 10 logarithm of the number, rounded down.

Returns None if the number is zero.

Source

pub const fn saturating_add(self, rhs: Self) -> Self

Saturating addition. Adds a positive integer to another positive integer. Returns PositiveI64::MAX on overflow.

Source

pub const fn saturating_sub(self, rhs: Self) -> Self

Saturating subtraction. Subtracts a positive integer from another positive integer. Returns 0 if the result would overflow into a negative integer.

Source

pub const fn saturating_mul(self, rhs: Self) -> Self

Saturating multiplication. Multiplies a positive integer by another positive integer, returning a positive result. Returns PositiveI64::MAX on overflow.

Source

pub const fn saturating_pow(self, rhs: u32) -> Self

Saturating integer exponentiation. Raises positive value to an integer power. Returns PositiveI64::MAX on overflow.

Trait Implementations§

Source§

impl Binary for PositiveI64

Source§

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

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

impl BitAnd<NegativeI64> for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: NegativeI64) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd<PositiveI64> for NegativeI64

Source§

type Output = PositiveI64

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: PositiveI64) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd<PositiveI64> for i64

Source§

type Output = PositiveI64

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: PositiveI64) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd<i64> for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: i64) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAndAssign<NegativeI64> for PositiveI64

Source§

fn bitand_assign(&mut self, rhs: NegativeI64)

Performs the &= operation. Read more
Source§

impl BitAndAssign<i64> for PositiveI64

Source§

fn bitand_assign(&mut self, rhs: i64)

Performs the &= operation. Read more
Source§

impl BitAndAssign for PositiveI64

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr<NegativeI64> for PositiveI64

Source§

type Output = NegativeI64

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: NegativeI64) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr<PositiveI64> for NegativeI64

Source§

type Output = NegativeI64

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: PositiveI64) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOrAssign<PositiveI64> for NegativeI64

Source§

fn bitor_assign(&mut self, rhs: PositiveI64)

Performs the |= operation. Read more
Source§

impl BitOrAssign for PositiveI64

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor<NegativeI64> for PositiveI64

Source§

type Output = NegativeI64

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: NegativeI64) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor<PositiveI64> for NegativeI64

Source§

type Output = NegativeI64

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: PositiveI64) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXorAssign<PositiveI64> for NegativeI64

Source§

fn bitxor_assign(&mut self, rhs: PositiveI64)

Performs the ^= operation. Read more
Source§

impl BitXorAssign for PositiveI64

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for PositiveI64

Source§

fn clone(&self) -> PositiveI64

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 Debug for PositiveI64

Source§

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

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

impl Default for PositiveI64

Source§

fn default() -> Self

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

impl Display for PositiveI64

Source§

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

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

impl Div<u64> for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign<u64> for PositiveI64

Source§

fn div_assign(&mut self, rhs: u64)

Performs the /= operation. Read more
Source§

impl DivAssign for PositiveI64

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl From<PositiveI16> for PositiveI64

Source§

fn from(value: PositiveI16) -> Self

Converts to this type from the input type.
Source§

impl From<PositiveI32> for PositiveI64

Source§

fn from(value: PositiveI32) -> Self

Converts to this type from the input type.
Source§

impl From<PositiveI64> for i128

Source§

fn from(value: PositiveI64) -> Self

Converts to this type from the input type.
Source§

impl From<PositiveI64> for i64

Source§

fn from(value: PositiveI64) -> Self

Converts to this type from the input type.
Source§

impl From<PositiveI64> for u128

Source§

fn from(value: PositiveI64) -> Self

Converts to this type from the input type.
Source§

impl From<PositiveI64> for u64

Source§

fn from(value: PositiveI64) -> Self

Converts to this type from the input type.
Source§

impl From<PositiveI8> for PositiveI64

Source§

fn from(value: PositiveI8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for PositiveI64

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for PositiveI64

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for PositiveI64

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl FromStr for PositiveI64

Source§

type Err = IntErrorKind

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 Hash for PositiveI64

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 LowerHex for PositiveI64

Source§

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

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

impl Not for PositiveI64

Source§

type Output = NegativeI64

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Octal for PositiveI64

Source§

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

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

impl Ord for PositiveI64

Source§

fn cmp(&self, rhs: &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 PartialEq for PositiveI64

Source§

fn eq(&self, rhs: &Self) -> 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 PartialOrd for PositiveI64

Source§

fn partial_cmp(&self, rhs: &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 Rem<u64> for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl Rem for PositiveI64

Source§

type Output = PositiveI64

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl RemAssign<u64> for PositiveI64

Source§

fn rem_assign(&mut self, rhs: u64)

Performs the %= operation. Read more
Source§

impl RemAssign for PositiveI64

Source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
Source§

impl TryFrom<PositiveI64> for PositiveI16

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for PositiveI32

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for PositiveI8

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for PositiveIsize

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for i16

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for i32

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for i8

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for isize

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for u16

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for u32

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for u8

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<PositiveI64> for usize

Source§

type Error = TryFromIntError

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

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

Performs the conversion.
Source§

impl TryFrom<i128> for PositiveI64

Source§

type Error = TryFromIntError

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 PositiveI64

Source§

type Error = TryFromIntError

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 PositiveI64

Source§

type Error = TryFromIntError

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 PositiveI64

Source§

type Error = TryFromIntError

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 PositiveI64

Source§

type Error = TryFromIntError

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 PositiveI64

Source§

type Error = TryFromIntError

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 PositiveI64

Source§

type Error = TryFromIntError

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<u64> for PositiveI64

Source§

type Error = TryFromIntError

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<usize> for PositiveI64

Source§

type Error = TryFromIntError

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 UpperHex for PositiveI64

Source§

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

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

impl Copy for PositiveI64

Source§

impl Eq for PositiveI64

Auto Trait Implementations§

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.