pub struct u5(/* private fields */);Expand description
The 5-bit unsigned integer type.
Implementations§
Source§impl u5
impl u5
Sourcepub const MIN: u5
pub const MIN: u5
The smallest value that can be represented by this integer type.
§Examples
Basic usage:
assert_eq!(u5::MIN, u5::try_from(0u8).unwrap());Sourcepub const MAX: u5
pub const MAX: u5
The largest value that can be represented by this integer type.
§Examples
Basic usage:
assert_eq!(u5::MAX, u5::try_from(31u8).unwrap());Sourcepub fn from_be_bytes(bytes: [u8; 1]) -> Self
pub fn from_be_bytes(bytes: [u8; 1]) -> Self
Create a native endian integer value from its representation as a byte array in big endian.
Sourcepub fn from_le_bytes(bytes: [u8; 1]) -> Self
pub fn from_le_bytes(bytes: [u8; 1]) -> Self
Create a native endian integer value from its representation as a byte array in little endian.
Sourcepub fn from_ne_bytes(bytes: [u8; 1]) -> Self
pub fn from_ne_bytes(bytes: [u8; 1]) -> 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; 1]
pub fn to_be_bytes(self) -> [u8; 1]
Return the memory representation of this integer as a byte array in big-endian (network) byte order.
Sourcepub fn to_le_bytes(self) -> [u8; 1]
pub fn to_le_bytes(self) -> [u8; 1]
Return the memory representation of this integer as a byte array in little-endian byte order.
Sourcepub fn to_ne_bytes(self) -> [u8; 1]
pub fn to_ne_bytes(self) -> [u8; 1]
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<u5, ParseIntError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<u5, 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-9a-zA-Z
§Panics
This function panics if radix is not in the range from 2 to 36.
Sourcepub fn pow(self, exp: u32) -> u5
pub fn pow(self, exp: u32) -> u5
Raises self to the power of exp, using exponentiation by squaring.
Sourcepub fn checked_add(self, rhs: u5) -> Option<u5>
pub fn checked_add(self, rhs: u5) -> Option<u5>
Checked integer addition. Computes self + rhs, returning None if overflow occurred.
Sourcepub fn checked_div(self, rhs: u5) -> Option<u5>
pub fn checked_div(self, rhs: u5) -> Option<u5>
Checked integer division. Computes self / rhs, returning None if rhs == 0.
Sourcepub fn checked_mul(self, rhs: u5) -> Option<u5>
pub fn checked_mul(self, rhs: u5) -> Option<u5>
Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.
Sourcepub fn checked_sub(self, rhs: u5) -> Option<u5>
pub fn checked_sub(self, rhs: u5) -> Option<u5>
Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.
Sourcepub fn wrapping_add(self, rhs: u5) -> u5
pub fn wrapping_add(self, rhs: u5) -> u5
Wrapping (modular) addition. Computes self + rhs, wrapping around at
the boundary of the type.
§Examples
Basic usage:
assert_eq!(u5::MAX.wrapping_add(u5::try_from(1u8).unwrap()), u5::MIN);Sourcepub fn wrapping_sub(self, rhs: u5) -> u5
pub fn wrapping_sub(self, rhs: u5) -> u5
Wrapping (modular) subtraction. Computes self - rhs, wrapping around
at the boundary of the type.