#[repr(C, align(1))]pub struct PositiveI8 { /* private fields */ }Expand description
A signed value that is known to be positive.
This enables some memory layout optimization.
For example, Option<PositiveI8> is the same size as i8.
Implementations§
Source§impl PositiveI8
impl PositiveI8
Sourcepub const BITS: u32 = 8u32
pub const BITS: u32 = 8u32
The size of this positive integer type in bits.
This value is equal to i8::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 i8::MAX.
Sourcepub const fn new(value: i8) -> Option<Self>
pub const fn new(value: i8) -> Option<Self>
Creates a PositiveI8 if the given value is positive.
Sourcepub const unsafe fn new_unchecked(value: i8) -> Self
pub const unsafe fn new_unchecked(value: i8) -> Self
Creates a PositiveI8 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<NegativeI8>
pub const fn checked_neg(self) -> Option<NegativeI8>
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: u8) -> Option<Self>
pub const fn checked_div_unsigned(self, rhs: u8) -> 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: u8) -> Option<Self>
pub const fn checked_rem_unsigned(self, rhs: u8) -> 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 PositiveI8::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 PositiveI8::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 PositiveI8::MAX on overflow.
Trait Implementations§
Source§impl Binary for PositiveI8
impl Binary for PositiveI8
Source§impl BitAnd<NegativeI8> for PositiveI8
impl BitAnd<NegativeI8> for PositiveI8
Source§type Output = PositiveI8
type Output = PositiveI8
& operator.Source§impl BitAnd<PositiveI8> for NegativeI8
impl BitAnd<PositiveI8> for NegativeI8
Source§type Output = PositiveI8
type Output = PositiveI8
& operator.Source§impl BitAnd<PositiveI8> for i8
impl BitAnd<PositiveI8> for i8
Source§type Output = PositiveI8
type Output = PositiveI8
& operator.Source§impl BitAnd<i8> for PositiveI8
impl BitAnd<i8> for PositiveI8
Source§impl BitAnd for PositiveI8
impl BitAnd for PositiveI8
Source§impl BitAndAssign<NegativeI8> for PositiveI8
impl BitAndAssign<NegativeI8> for PositiveI8
Source§fn bitand_assign(&mut self, rhs: NegativeI8)
fn bitand_assign(&mut self, rhs: NegativeI8)
&= operation. Read moreSource§impl BitAndAssign<i8> for PositiveI8
impl BitAndAssign<i8> for PositiveI8
Source§fn bitand_assign(&mut self, rhs: i8)
fn bitand_assign(&mut self, rhs: i8)
&= operation. Read moreSource§impl BitAndAssign for PositiveI8
impl BitAndAssign for PositiveI8
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOr<NegativeI8> for PositiveI8
impl BitOr<NegativeI8> for PositiveI8
Source§type Output = NegativeI8
type Output = NegativeI8
| operator.Source§impl BitOr<PositiveI8> for NegativeI8
impl BitOr<PositiveI8> for NegativeI8
Source§type Output = NegativeI8
type Output = NegativeI8
| operator.Source§impl BitOr for PositiveI8
impl BitOr for PositiveI8
Source§impl BitOrAssign<PositiveI8> for NegativeI8
impl BitOrAssign<PositiveI8> for NegativeI8
Source§fn bitor_assign(&mut self, rhs: PositiveI8)
fn bitor_assign(&mut self, rhs: PositiveI8)
|= operation. Read moreSource§impl BitOrAssign for PositiveI8
impl BitOrAssign for PositiveI8
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitXor<NegativeI8> for PositiveI8
impl BitXor<NegativeI8> for PositiveI8
Source§type Output = NegativeI8
type Output = NegativeI8
^ operator.Source§impl BitXor<PositiveI8> for NegativeI8
impl BitXor<PositiveI8> for NegativeI8
Source§type Output = NegativeI8
type Output = NegativeI8
^ operator.Source§impl BitXor for PositiveI8
impl BitXor for PositiveI8
Source§impl BitXorAssign<PositiveI8> for NegativeI8
impl BitXorAssign<PositiveI8> for NegativeI8
Source§fn bitxor_assign(&mut self, rhs: PositiveI8)
fn bitxor_assign(&mut self, rhs: PositiveI8)
^= operation. Read moreSource§impl BitXorAssign for PositiveI8
impl BitXorAssign for PositiveI8
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl Clone for PositiveI8
impl Clone for PositiveI8
Source§fn clone(&self) -> PositiveI8
fn clone(&self) -> PositiveI8
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PositiveI8
impl Debug for PositiveI8
Source§impl Default for PositiveI8
impl Default for PositiveI8
Source§impl Display for PositiveI8
impl Display for PositiveI8
Source§impl Div<u8> for PositiveI8
impl Div<u8> for PositiveI8
Source§impl Div for PositiveI8
impl Div for PositiveI8
Source§impl DivAssign<u8> for PositiveI8
impl DivAssign<u8> for PositiveI8
Source§fn div_assign(&mut self, rhs: u8)
fn div_assign(&mut self, rhs: u8)
/= operation. Read moreSource§impl DivAssign for PositiveI8
impl DivAssign for PositiveI8
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl From<PositiveI8> for PositiveI16
impl From<PositiveI8> for PositiveI16
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for PositiveI32
impl From<PositiveI8> for PositiveI32
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> 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<PositiveI8> for PositiveIsize
impl From<PositiveI8> for PositiveIsize
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for i128
impl From<PositiveI8> for i128
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for i16
impl From<PositiveI8> for i16
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for i32
impl From<PositiveI8> for i32
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for i64
impl From<PositiveI8> for i64
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for i8
impl From<PositiveI8> for i8
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for isize
impl From<PositiveI8> for isize
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for u128
impl From<PositiveI8> for u128
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for u16
impl From<PositiveI8> for u16
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for u32
impl From<PositiveI8> for u32
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for u64
impl From<PositiveI8> for u64
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for u8
impl From<PositiveI8> for u8
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl From<PositiveI8> for usize
impl From<PositiveI8> for usize
Source§fn from(value: PositiveI8) -> Self
fn from(value: PositiveI8) -> Self
Source§impl FromStr for PositiveI8
impl FromStr for PositiveI8
Source§impl Hash for PositiveI8
impl Hash for PositiveI8
Source§impl LowerHex for PositiveI8
impl LowerHex for PositiveI8
Source§impl Not for PositiveI8
impl Not for PositiveI8
Source§impl Octal for PositiveI8
impl Octal for PositiveI8
Source§impl Ord for PositiveI8
impl Ord for PositiveI8
Source§impl PartialEq for PositiveI8
impl PartialEq for PositiveI8
Source§impl PartialOrd for PositiveI8
impl PartialOrd for PositiveI8
Source§impl Rem<u8> for PositiveI8
impl Rem<u8> for PositiveI8
Source§impl Rem for PositiveI8
impl Rem for PositiveI8
Source§impl RemAssign<u8> for PositiveI8
impl RemAssign<u8> for PositiveI8
Source§fn rem_assign(&mut self, rhs: u8)
fn rem_assign(&mut self, rhs: u8)
%= operation. Read moreSource§impl RemAssign for PositiveI8
impl RemAssign for PositiveI8
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read more