#[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
impl PositiveI64
Sourcepub const BITS: u32 = 64u32
pub const BITS: u32 = 64u32
The size of this positive integer type in bits.
This value is equal to i64::BITS.
Sourcepub const MIN: Self
pub const MIN: Self
The smallest value that can be represented by this positive integer type, 0.
Sourcepub const MAX: Self
pub const MAX: Self
The largest value that can be represented by this positive integer type, equal to i64::MAX.
Sourcepub const fn new(value: i64) -> Option<Self>
pub const fn new(value: i64) -> Option<Self>
Creates a PositiveI64 if the given value is positive.
Sourcepub const unsafe fn new_unchecked(value: i64) -> Self
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.
Sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representation of self.
Sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of self.
Sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary representation of self.
Sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representation of self.
Sourcepub const fn is_power_of_two(self) -> bool
pub const fn is_power_of_two(self) -> bool
Returns true if and only if self == (1 << k) for some k.
Sourcepub const fn ilog2(self) -> u32
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.
Sourcepub const fn ilog10(self) -> u32
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.
Sourcepub const fn checked_neg(self) -> Option<NegativeI64>
pub const fn checked_neg(self) -> Option<NegativeI64>
Checked negation. Computes -self, returning None if self == 0.
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
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.
Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
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.
Sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
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.
Sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
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.
Sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
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.
Sourcepub const fn checked_div_unsigned(self, rhs: u64) -> Option<Self>
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.
Sourcepub const fn checked_rem_unsigned(self, rhs: u64) -> Option<Self>
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.
Sourcepub const fn checked_pow(self, rhs: u32) -> Option<Self>
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.
Sourcepub const fn checked_next_power_of_two(self) -> Option<Self>
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.
Sourcepub const fn checked_ilog2(self) -> Option<u32>
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.
Sourcepub const fn checked_ilog10(self) -> Option<u32>
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.
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Saturating addition. Adds a positive integer to another positive integer.
Returns PositiveI64::MAX on overflow.
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
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.
Sourcepub const fn saturating_mul(self, rhs: Self) -> Self
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.
Sourcepub const fn saturating_pow(self, rhs: u32) -> Self
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
impl Binary for PositiveI64
Source§impl BitAnd<NegativeI64> for PositiveI64
impl BitAnd<NegativeI64> for PositiveI64
Source§type Output = PositiveI64
type Output = PositiveI64
& operator.Source§impl BitAnd<PositiveI64> for NegativeI64
impl BitAnd<PositiveI64> for NegativeI64
Source§type Output = PositiveI64
type Output = PositiveI64
& operator.Source§impl BitAnd<PositiveI64> for i64
impl BitAnd<PositiveI64> for i64
Source§type Output = PositiveI64
type Output = PositiveI64
& operator.Source§impl BitAnd<i64> for PositiveI64
impl BitAnd<i64> for PositiveI64
Source§impl BitAnd for PositiveI64
impl BitAnd for PositiveI64
Source§impl BitAndAssign<NegativeI64> for PositiveI64
impl BitAndAssign<NegativeI64> for PositiveI64
Source§fn bitand_assign(&mut self, rhs: NegativeI64)
fn bitand_assign(&mut self, rhs: NegativeI64)
&= operation. Read moreSource§impl BitAndAssign<i64> for PositiveI64
impl BitAndAssign<i64> for PositiveI64
Source§fn bitand_assign(&mut self, rhs: i64)
fn bitand_assign(&mut self, rhs: i64)
&= operation. Read moreSource§impl BitAndAssign for PositiveI64
impl BitAndAssign for PositiveI64
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOr<NegativeI64> for PositiveI64
impl BitOr<NegativeI64> for PositiveI64
Source§type Output = NegativeI64
type Output = NegativeI64
| operator.Source§impl BitOr<PositiveI64> for NegativeI64
impl BitOr<PositiveI64> for NegativeI64
Source§type Output = NegativeI64
type Output = NegativeI64
| operator.Source§impl BitOr for PositiveI64
impl BitOr for PositiveI64
Source§impl BitOrAssign<PositiveI64> for NegativeI64
impl BitOrAssign<PositiveI64> for NegativeI64
Source§fn bitor_assign(&mut self, rhs: PositiveI64)
fn bitor_assign(&mut self, rhs: PositiveI64)
|= operation. Read moreSource§impl BitOrAssign for PositiveI64
impl BitOrAssign for PositiveI64
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitXor<NegativeI64> for PositiveI64
impl BitXor<NegativeI64> for PositiveI64
Source§type Output = NegativeI64
type Output = NegativeI64
^ operator.Source§impl BitXor<PositiveI64> for NegativeI64
impl BitXor<PositiveI64> for NegativeI64
Source§type Output = NegativeI64
type Output = NegativeI64
^ operator.Source§impl BitXor for PositiveI64
impl BitXor for PositiveI64
Source§impl BitXorAssign<PositiveI64> for NegativeI64
impl BitXorAssign<PositiveI64> for NegativeI64
Source§fn bitxor_assign(&mut self, rhs: PositiveI64)
fn bitxor_assign(&mut self, rhs: PositiveI64)
^= operation. Read moreSource§impl BitXorAssign for PositiveI64
impl BitXorAssign for PositiveI64
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl Clone for PositiveI64
impl Clone for PositiveI64
Source§fn clone(&self) -> PositiveI64
fn clone(&self) -> PositiveI64
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PositiveI64
impl Debug for PositiveI64
Source§impl Default for PositiveI64
impl Default for PositiveI64
Source§impl Display for PositiveI64
impl Display for PositiveI64
Source§impl Div<u64> for PositiveI64
impl Div<u64> for PositiveI64
Source§impl Div for PositiveI64
impl Div for PositiveI64
Source§impl DivAssign<u64> for PositiveI64
impl DivAssign<u64> for PositiveI64
Source§fn div_assign(&mut self, rhs: u64)
fn div_assign(&mut self, rhs: u64)
/= operation. Read moreSource§impl DivAssign for PositiveI64
impl DivAssign for PositiveI64
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl From<PositiveI16> for PositiveI64
impl From<PositiveI16> for PositiveI64
Source§fn from(value: PositiveI16) -> Self
fn from(value: PositiveI16) -> Self
Source§impl From<PositiveI32> for PositiveI64
impl From<PositiveI32> for PositiveI64
Source§fn from(value: PositiveI32) -> Self
fn from(value: PositiveI32) -> Self
Source§impl From<PositiveI64> for i128
impl From<PositiveI64> for i128
Source§fn from(value: PositiveI64) -> Self
fn from(value: PositiveI64) -> Self
Source§impl From<PositiveI64> for i64
impl From<PositiveI64> for i64
Source§fn from(value: PositiveI64) -> Self
fn from(value: PositiveI64) -> Self
Source§impl From<PositiveI64> for u128
impl From<PositiveI64> for u128
Source§fn from(value: PositiveI64) -> Self
fn from(value: PositiveI64) -> Self
Source§impl From<PositiveI64> for u64
impl From<PositiveI64> for u64
Source§fn from(value: PositiveI64) -> Self
fn from(value: PositiveI64) -> Self
Source§impl From<PositiveI8> for PositiveI64
impl From<PositiveI8> for PositiveI64
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<u16> for PositiveI64
impl From<u16> for PositiveI64
Source§impl From<u32> for PositiveI64
impl From<u32> for PositiveI64
Source§impl From<u8> for PositiveI64
impl From<u8> for PositiveI64
Source§impl FromStr for PositiveI64
impl FromStr for PositiveI64
Source§impl Hash for PositiveI64
impl Hash for PositiveI64
Source§impl LowerHex for PositiveI64
impl LowerHex for PositiveI64
Source§impl Not for PositiveI64
impl Not for PositiveI64
Source§impl Octal for PositiveI64
impl Octal for PositiveI64
Source§impl Ord for PositiveI64
impl Ord for PositiveI64
Source§impl PartialEq for PositiveI64
impl PartialEq for PositiveI64
Source§impl PartialOrd for PositiveI64
impl PartialOrd for PositiveI64
Source§impl Rem<u64> for PositiveI64
impl Rem<u64> for PositiveI64
Source§impl Rem for PositiveI64
impl Rem for PositiveI64
Source§impl RemAssign<u64> for PositiveI64
impl RemAssign<u64> for PositiveI64
Source§fn rem_assign(&mut self, rhs: u64)
fn rem_assign(&mut self, rhs: u64)
%= operation. Read moreSource§impl RemAssign for PositiveI64
impl RemAssign for PositiveI64
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read more