u48

Struct u48 

Source
pub struct u48(/* private fields */);
Expand description

48-bit unsigned integer in the range 0..2^48

Implementations§

Source§

impl u48

Source

pub const BITS: u32 = 48u32

Bit dimension

Source

pub const MIN: u48

Minimum value

Source

pub const MAX: u48

Maximal value

Source

pub const ONE: u48

One value

Source

pub const ZERO: u48

One value

Source

pub const fn with(value: u64) -> u48

Creates a new value from a provided `value.

Panics if the value exceeds Self::MAX

Source

pub const fn to_u64(&self) -> u64

Returns inner u8 representation, which is always less or equal to Self::MAX

Source

pub const fn into_u64(self) -> u64

Returns inner u8 representation, which is always less or equal to Self::MAX

Source§

impl u48

Source

pub fn checked_add<T>(self, rhs: T) -> Option<u48>
where T: Into<u64>,

Checked integer addition. Computes self + rhs, returning None if overflow occurred.

Source

pub fn saturating_add<T>(self, rhs: T) -> u48
where T: Into<u64>,

Saturating integer addition. Computes self + rhs, saturating at the numeric bounds instead of overflowing.

Source

pub fn overflowing_add<T>(self, rhs: T) -> (u48, bool)
where T: Into<u64>,

Calculates self + rhs

Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.

Source

pub fn wrapping_add<T>(self, rhs: T) -> u48
where T: Into<u64>,

Wrapping (modular) addition. Computes self + rhs, wrapping around at the boundary of the type.

Source

pub fn checked_sub<T>(self, rhs: T) -> Option<u48>
where T: Into<u64>,

Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.

Source

pub fn saturating_sub<T>(self, rhs: T) -> u48
where T: Into<u64>,

Saturating integer subtraction. Computes self - rhs, saturating at the numeric bounds instead of overflowing.

Source

pub fn overflowing_sub<T>(self, rhs: T) -> (u48, bool)
where T: Into<u64>,

Calculates self - rhs

Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.

Source

pub fn wrapping_sub<T>(self, rhs: T) -> u48
where T: Into<u64>,

Wrapping (modular) subtraction. Computes self - rhs, wrapping around at the boundary of the type.

Source

pub fn checked_mul<T>(self, rhs: T) -> Option<u48>
where T: Into<u64>,

Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.

Source

pub fn saturating_mul<T>(self, rhs: T) -> u48
where T: Into<u64>,

Saturating integer multiplication. Computes self * rhs, saturating at the numeric bounds instead of overflowing.

Source

pub fn overflowing_mul<T>(self, rhs: T) -> (u48, bool)
where T: Into<u64>,

Calculates self * rhs

Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.

Source

pub fn wrapping_mul<T>(self, rhs: T) -> u48
where T: Into<u64>,

Wrapping (modular) multiplication. Computes self * rhs, wrapping around at the boundary of the type.

Source

pub fn div_rem(self, other: u48) -> Result<(u48, u48), DivError>

Source§

impl u48

Source

pub fn from_le_bytes(bytes: [u8; 6]) -> u48

Create a native endian integer value from its representation as a byte array in little endian.

Source

pub fn to_le_bytes(self) -> [u8; 6]

Return the memory representation of this integer as a byte array in little-endian byte order.

Source

pub fn from_be_bytes(bytes: [u8; 6]) -> u48

Create a native endian integer value from its representation as a byte array in big endian.

Source

pub fn to_be_bytes(self) -> [u8; 6]

Return the memory representation of this integer as a byte array in big-endian byte order.

Source

pub const fn to_i64(&self) -> i64

Converts into i64 type.

Source

pub const fn to_i128(&self) -> i128

Converts into i128 type.

Source

pub const fn to_isize(&self) -> isize

Converts into isize type.

Source

pub const fn to_u128(&self) -> u128

Converts into i128 type.

Source

pub const fn to_usize(&self) -> usize

Converts into usize type.

Source

pub const fn into_i64(self) -> i64

Converts into i64 type.

Source

pub const fn into_i128(self) -> i128

Converts into i128 type.

Source

pub const fn into_isize(self) -> isize

Converts into isize type.

Source

pub const fn into_u128(self) -> u128

Converts into u128 type.

Source

pub const fn into_usize(self) -> usize

Converts into usize type.

Trait Implementations§

Source§

impl<T> Add<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> <&u48 as Add<T>>::Output

Performs the + operation. Read more
Source§

impl<T> Add<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> <u48 as Add<T>>::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign<T> for u48
where T: Into<u64>,

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl AsRef<u64> for u48

Source§

fn as_ref(&self) -> &u64

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Binary for u48

Source§

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

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

impl<T> BitAnd<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: T) -> <&u48 as BitAnd<T>>::Output

Performs the & operation. Read more
Source§

impl<T> BitAnd<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: T) -> <u48 as BitAnd<T>>::Output

Performs the & operation. Read more
Source§

impl<T> BitAndAssign<T> for u48
where T: Into<u64>,

Source§

fn bitand_assign(&mut self, rhs: T)

Performs the &= operation. Read more
Source§

impl<T> BitOr<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: T) -> <&u48 as BitOr<T>>::Output

Performs the | operation. Read more
Source§

impl<T> BitOr<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: T) -> <u48 as BitOr<T>>::Output

Performs the | operation. Read more
Source§

impl<T> BitOrAssign<T> for u48
where T: Into<u64>,

Source§

fn bitor_assign(&mut self, rhs: T)

Performs the |= operation. Read more
Source§

impl<T> BitXor<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: T) -> <&u48 as BitXor<T>>::Output

Performs the ^ operation. Read more
Source§

impl<T> BitXor<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: T) -> <u48 as BitXor<T>>::Output

Performs the ^ operation. Read more
Source§

impl<T> BitXorAssign<T> for u48
where T: Into<u64>,

Source§

fn bitxor_assign(&mut self, rhs: T)

Performs the ^= operation. Read more
Source§

impl Clone for u48

Source§

fn clone(&self) -> u48

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 u48

Source§

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

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

impl Default for u48

Source§

fn default() -> u48

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

impl Display for u48

Source§

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

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

impl<T> Div<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> <&u48 as Div<T>>::Output

Performs the / operation. Read more
Source§

impl<T> Div<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> <u48 as Div<T>>::Output

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for u48
where T: Into<u64>,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl FromStr for u48

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<u48, <u48 as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for u48

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

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 u48

Source§

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

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

impl<T> Mul<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> <&u48 as Mul<T>>::Output

Performs the * operation. Read more
Source§

impl<T> Mul<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> <u48 as Mul<T>>::Output

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for u48
where T: Into<u64>,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl Octal for u48

Source§

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

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

impl Ord for u48

Source§

fn cmp(&self, other: &u48) -> 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 u48

Source§

fn eq(&self, other: &u48) -> 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 u48

Source§

fn partial_cmp(&self, other: &u48) -> 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<T> Rem<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> <&u48 as Rem<T>>::Output

Performs the % operation. Read more
Source§

impl<T> Rem<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> <u48 as Rem<T>>::Output

Performs the % operation. Read more
Source§

impl<T> RemAssign<T> for u48
where T: Into<u64>,

Source§

fn rem_assign(&mut self, rhs: T)

Performs the %= operation. Read more
Source§

impl<T> Shl<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: T) -> <&u48 as Shl<T>>::Output

Performs the << operation. Read more
Source§

impl<T> Shl<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: T) -> <u48 as Shl<T>>::Output

Performs the << operation. Read more
Source§

impl<T> ShlAssign<T> for u48
where T: Into<u64>,

Source§

fn shl_assign(&mut self, rhs: T)

Performs the <<= operation. Read more
Source§

impl<T> Shr<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: T) -> <&u48 as Shr<T>>::Output

Performs the >> operation. Read more
Source§

impl<T> Shr<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: T) -> <u48 as Shr<T>>::Output

Performs the >> operation. Read more
Source§

impl<T> ShrAssign<T> for u48
where T: Into<u64>,

Source§

fn shr_assign(&mut self, rhs: T)

Performs the >>= operation. Read more
Source§

impl<T> Sub<T> for &u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> <&u48 as Sub<T>>::Output

Performs the - operation. Read more
Source§

impl<T> Sub<T> for u48
where T: Into<u64>,

Source§

type Output = u48

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> <u48 as Sub<T>>::Output

Performs the - operation. Read more
Source§

impl<T> SubAssign<T> for u48
where T: Into<u64>,

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl TryFrom<u64> for u48

Source§

type Error = OverflowError<u64>

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

fn try_from(value: u64) -> Result<u48, <u48 as TryFrom<u64>>::Error>

Performs the conversion.
Source§

impl UpperHex for u48

Source§

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

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

impl Copy for u48

Source§

impl Eq for u48

Source§

impl StructuralPartialEq for u48

Auto Trait Implementations§

§

impl Freeze for u48

§

impl RefUnwindSafe for u48

§

impl Send for u48

§

impl Sync for u48

§

impl Unpin for u48

§

impl UnwindSafe for u48

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes