pub struct u59(_);
Expand description
The 59-bit unsigned integer type.
Implementations§
source§impl u59
impl u59
sourcepub const MIN: u59 = _
pub const MIN: u59 = _
The smallest value that can be represented by this integer type.
Examples
Basic usage:
assert_eq!(u59::MIN, u59::try_from(0u64).unwrap());
sourcepub const MAX: u59 = _
pub const MAX: u59 = _
The largest value that can be represented by this integer type.
Examples
Basic usage:
assert_eq!(u59::MAX, u59::try_from(576460752303423487u64).unwrap());
sourcepub fn from_be_bytes(bytes: [u8; 8]) -> Self
pub fn from_be_bytes(bytes: [u8; 8]) -> Self
Create a native endian integer value from its representation as a byte array in big endian.
sourcepub fn from_le_bytes(bytes: [u8; 8]) -> Self
pub fn from_le_bytes(bytes: [u8; 8]) -> Self
Create a native endian integer value from its representation as a byte array in little endian.
sourcepub fn from_ne_bytes(bytes: [u8; 8]) -> Self
pub fn from_ne_bytes(bytes: [u8; 8]) -> Self
Create a native endian integer value from its memory representation as a byte array in native endianness.
As the target platform’s native endianness is used, portable code likely
wants to use from_be_bytes
or from_le_bytes
, as appropriate instead.
sourcepub fn to_be_bytes(self) -> [u8; 8]
pub fn to_be_bytes(self) -> [u8; 8]
Return the memory representation of this integer as a byte array in big-endian (network) byte order.
sourcepub fn to_le_bytes(self) -> [u8; 8]
pub fn to_le_bytes(self) -> [u8; 8]
Return the memory representation of this integer as a byte array in little-endian byte order.
sourcepub fn to_ne_bytes(self) -> [u8; 8]
pub fn to_ne_bytes(self) -> [u8; 8]
Return the memory representation of this integer as a byte array in native byte order.
As the target platform’s native endianness is used, portable code should
use to_be_bytes
or to_le_bytes
, as appropriate, instead.
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<u59, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<u59, ParseIntError>
Converts a string slice in a given base to an integer.
The string is expected to be an optional + sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:
0-9
a-z
A-Z
Panics
This function panics if radix
is not in the range from 2 to 36.
sourcepub fn pow(self, exp: u32) -> u59
pub fn pow(self, exp: u32) -> u59
Raises self to the power of exp
, using exponentiation by squaring.
sourcepub fn checked_add(self, rhs: u59) -> Option<u59>
pub fn checked_add(self, rhs: u59) -> Option<u59>
Checked integer addition. Computes self + rhs
, returning None
if overflow occurred.
sourcepub fn checked_div(self, rhs: u59) -> Option<u59>
pub fn checked_div(self, rhs: u59) -> Option<u59>
Checked integer division. Computes self / rhs
, returning None
if rhs == 0
.
sourcepub fn checked_mul(self, rhs: u59) -> Option<u59>
pub fn checked_mul(self, rhs: u59) -> Option<u59>
Checked integer multiplication. Computes self * rhs
, returning None
if overflow occurred.
sourcepub fn checked_sub(self, rhs: u59) -> Option<u59>
pub fn checked_sub(self, rhs: u59) -> Option<u59>
Checked integer subtraction. Computes self - rhs
, returning None
if overflow occurred.
sourcepub fn wrapping_add(self, rhs: u59) -> u59
pub fn wrapping_add(self, rhs: u59) -> u59
Wrapping (modular) addition. Computes self + rhs
, wrapping around at
the boundary of the type.
Examples
Basic usage:
assert_eq!(u59::MAX.wrapping_add(u59::try_from(1u64).unwrap()), u59::MIN);
sourcepub fn wrapping_sub(self, rhs: u59) -> u59
pub fn wrapping_sub(self, rhs: u59) -> u59
Wrapping (modular) subtraction. Computes self - rhs
, wrapping around
at the boundary of the type.
Trait Implementations§
source§impl<'de> Deserialize<'de> for u59
impl<'de> Deserialize<'de> for u59
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Num for u59
Available on crate feature num-traits
only.
impl Num for u59
num-traits
only.type FromStrRadixErr = ParseIntError
source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moresource§impl Ord for u59
impl Ord for u59
source§impl PartialOrd<u59> for u59
impl PartialOrd<u59> for u59
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more