Struct u24

Source
#[repr(C, align(4))]
pub struct u24 { /* private fields */ }
Expand description

An unsigned little-endian encoded 24-bit integer.

§Memory Layout

The u24 type has the same size (4 bytes), alignment (4 bytes), and memory layout as a little-endian encoded u32. The most significant byte is always zero, ensuring that the value never exceeds the 24-bit range.

Memory layout (little-endian):
[byte0] [byte1] [byte2] [0x00]

This layout ensures that u24 values can be safely transmuted to/from u32 values while maintaining the 24-bit constraint.

§Examples

use u24::u24;

// Create from literal values
let val = u24!(0x123456);
assert_eq!(val.into_u32(), 0x00_123456);

// Create from byte array
let val = u24::from_le_bytes([0x56, 0x34, 0x12]);
assert_eq!(val.into_u32(), 0x00_123456);

// Convert back to bytes
assert_eq!(val.to_le_bytes(), [0x56, 0x34, 0x12]);

// Arithmetic operations
let a = u24!(1000);
let b = u24!(2000);
let sum = a + b;
assert_eq!(sum, u24!(3000));

Implementations§

Source§

impl u24

Source

pub const MAX: u24

The largest value that can be represented by this integer type.

Source

pub const MIN: u24

The smallest value that can be represented by this integer type.

Source

pub const BITS: u32 = 24u32

The number of bits in this integer type (24).

Source

pub const fn from_le_bytes(bytes: [u8; 3]) -> Self

Creates a u24 from a little-endian byte array.

§Examples
use u24::u24;

let val = u24::from_le_bytes([0x34, 0x12, 0xAB]);
assert_eq!(val.into_u32(), 0x00_AB1234);
Source

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

Returns the memory representation of this u24 as a little-endian byte array.

§Examples
use u24::u24;

let val = u24::truncating_from_u32(0x00_AB1234);
assert_eq!(val.to_le_bytes(), [0x34, 0x12, 0xAB]);
Source

pub const fn into_u32(self) -> u32

Converts this u24 to a u32 representation.

§Examples
use u24::u24;

let val = u24::from_le_bytes([0x34, 0x12, 0xAB]);
assert_eq!(val.into_u32(), 0x00_AB1234);

assert_eq!(u24::MAX.into_u32(), 0x00_FFFFFF);
assert_eq!(u24::MIN.into_u32(), 0x00_000000);
Source

pub const fn truncating_from_u32(v: u32) -> Self

Creates a u24 from a u32, truncating the most significant bytes if necessary.

§Examples
use u24::u24;

let val = u24::truncating_from_u32(0x01_234567);
assert_eq!(val.into_u32(), 0x00_234567);

let val = u24::truncating_from_u32(0xFF_FFFFFF);
assert_eq!(val.into_u32(), 0x00_FFFFFF);
Source

pub const fn checked_from_u32(v: u32) -> Option<Self>

Creates a u24 from a u32 if it fits, otherwise returns None.

This function returns None if the input value is greater than u24::MAX.

§Examples
use u24::u24;

assert_eq!(u24::checked_from_u32(0x00_FFFFFF), Some(u24::MAX));
assert_eq!(u24::checked_from_u32(0x01_000000), None);
assert_eq!(u24::checked_from_u32(0), Some(u24::MIN));
Source

pub const fn saturating_from_u32(v: u32) -> Self

Creates a u24 from a u32, saturating at the bounds.

If the input value is greater than u24::MAX, returns u24::MAX.

§Examples
use u24::u24;

assert_eq!(u24::saturating_from_u32(0x00_FFFFFF), u24::MAX);
assert_eq!(u24::saturating_from_u32(0x01_000000), u24::MAX);
assert_eq!(u24::saturating_from_u32(0x00_123456), u24::truncating_from_u32(0x00_123456));
Source

pub const fn checked_add(self, other: Self) -> Option<Self>

Checked integer addition. Returns None on overflow.

§Examples
use u24::u24;

assert_eq!(u24!(100).checked_add(u24!(50)), Some(u24!(150)));
assert_eq!(u24::MAX.checked_add(u24!(1)), None);
Source

pub const fn checked_sub(self, other: Self) -> Option<Self>

Checked integer subtraction. Returns None on underflow.

§Examples
use u24::u24;

assert_eq!(u24!(100).checked_sub(u24!(50)), Some(u24!(50)));
assert_eq!(u24!(0).checked_sub(u24!(1)), None);
Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Checked integer multiplication. Returns None on overflow.

§Examples
use u24::u24;

assert_eq!(u24!(100).checked_mul(u24!(200)), Some(u24!(20000)));
assert_eq!(u24::MAX.checked_mul(u24!(2)), None);
Source

pub const fn checked_div(self, other: Self) -> Option<Self>

Checked integer division. Returns None if other is zero.

§Examples
use u24::u24;

assert_eq!(u24!(100).checked_div(u24!(5)), Some(u24!(20)));
assert_eq!(u24!(100).checked_div(u24!(0)), None);
Source

pub const fn saturating_add(self, other: Self) -> Self

Saturating integer addition. Clamps the result at the maximum value.

§Examples
use u24::u24;

assert_eq!(u24!(100).saturating_add(u24!(50)), u24!(150));
assert_eq!(u24::MAX.saturating_add(u24!(1)), u24::MAX);
Source

pub const fn saturating_sub(self, other: Self) -> Self

Saturating integer subtraction. Clamps the result at the minimum value.

§Examples
use u24::u24;

assert_eq!(u24!(100).saturating_sub(u24!(50)), u24!(50));
assert_eq!(u24!(10).saturating_sub(u24!(50)), u24::MIN);
Source

pub const fn saturating_mul(self, other: Self) -> Self

Saturating integer multiplication. Clamps the result at the maximum value.

§Examples
use u24::u24;

assert_eq!(u24!(100).saturating_mul(u24!(200)), u24!(20000));
assert_eq!(u24::MAX.saturating_mul(u24!(2)), u24::MAX);

Trait Implementations§

Source§

impl Add<&u24> for &u24

Source§

type Output = u24

The resulting type after applying the + operator.
Source§

fn add(self, other: &u24) -> u24

Performs the + operation. Read more
Source§

impl Add<&u24> for u24

Source§

type Output = u24

The resulting type after applying the + operator.
Source§

fn add(self, other: &u24) -> Self

Performs the + operation. Read more
Source§

impl Add<u24> for &u24

Source§

type Output = u24

The resulting type after applying the + operator.
Source§

fn add(self, other: u24) -> u24

Performs the + operation. Read more
Source§

impl Add for u24

Source§

type Output = u24

The resulting type after applying the + operator.
Source§

fn add(self, other: u24) -> Self

Performs the + operation. Read more
Source§

impl AddAssign<&u24> for u24

Source§

fn add_assign(&mut self, rhs: &u24)

Performs the += operation. Read more
Source§

impl AddAssign for u24

Source§

fn add_assign(&mut self, rhs: u24)

Performs the += operation. Read more
Source§

impl AsPrimitive<i16> for u24

Source§

fn as_(self) -> i16

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<i32> for u24

Source§

fn as_(self) -> i32

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<i64> for u24

Source§

fn as_(self) -> i64

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<i8> for u24

Source§

fn as_(self) -> i8

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u16> for u24

Source§

fn as_(self) -> u16

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for i16

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for i32

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for i64

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for i8

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for u16

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for u24

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for u32

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for u64

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for u8

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u24> for usize

Source§

fn as_(self) -> u24

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u32> for u24

Source§

fn as_(self) -> u32

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u64> for u24

Source§

fn as_(self) -> u64

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<u8> for u24

Source§

fn as_(self) -> u8

Convert a value to another, using the as operator.
Source§

impl AsPrimitive<usize> for u24

Source§

fn as_(self) -> usize

Convert a value to another, using the as operator.
Source§

impl BitAnd<&u24> for &u24

Source§

type Output = u24

The resulting type after applying the & operator.
Source§

fn bitand(self, other: &u24) -> u24

Performs the & operation. Read more
Source§

impl BitAnd<&u24> for u24

Source§

type Output = u24

The resulting type after applying the & operator.
Source§

fn bitand(self, other: &u24) -> Self

Performs the & operation. Read more
Source§

impl BitAnd<u24> for &u24

Source§

type Output = u24

The resulting type after applying the & operator.
Source§

fn bitand(self, other: u24) -> u24

Performs the & operation. Read more
Source§

impl BitAnd for u24

Source§

type Output = u24

The resulting type after applying the & operator.
Source§

fn bitand(self, other: u24) -> Self

Performs the & operation. Read more
Source§

impl BitAndAssign<&u24> for u24

Source§

fn bitand_assign(&mut self, rhs: &u24)

Performs the &= operation. Read more
Source§

impl BitAndAssign for u24

Source§

fn bitand_assign(&mut self, rhs: u24)

Performs the &= operation. Read more
Source§

impl BitOr<&u24> for &u24

Source§

type Output = u24

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &u24) -> u24

Performs the | operation. Read more
Source§

impl BitOr<&u24> for u24

Source§

type Output = u24

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &u24) -> Self

Performs the | operation. Read more
Source§

impl BitOr<u24> for &u24

Source§

type Output = u24

The resulting type after applying the | operator.
Source§

fn bitor(self, other: u24) -> u24

Performs the | operation. Read more
Source§

impl BitOr for u24

Source§

type Output = u24

The resulting type after applying the | operator.
Source§

fn bitor(self, other: u24) -> Self

Performs the | operation. Read more
Source§

impl BitOrAssign<&u24> for u24

Source§

fn bitor_assign(&mut self, rhs: &u24)

Performs the |= operation. Read more
Source§

impl BitOrAssign for u24

Source§

fn bitor_assign(&mut self, rhs: u24)

Performs the |= operation. Read more
Source§

impl BitXor<&u24> for &u24

Source§

type Output = u24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: &u24) -> u24

Performs the ^ operation. Read more
Source§

impl BitXor<&u24> for u24

Source§

type Output = u24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: &u24) -> Self

Performs the ^ operation. Read more
Source§

impl BitXor<u24> for &u24

Source§

type Output = u24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: u24) -> u24

Performs the ^ operation. Read more
Source§

impl BitXor for u24

Source§

type Output = u24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: u24) -> Self

Performs the ^ operation. Read more
Source§

impl BitXorAssign<&u24> for u24

Source§

fn bitxor_assign(&mut self, rhs: &u24)

Performs the ^= operation. Read more
Source§

impl BitXorAssign for u24

Source§

fn bitxor_assign(&mut self, rhs: u24)

Performs the ^= operation. Read more
Source§

impl Bounded for u24

Source§

fn min_value() -> Self

Returns the smallest finite number this type can represent
Source§

fn max_value() -> Self

Returns the largest finite number this type can represent
Source§

impl CheckedAdd for u24

Source§

fn checked_add(&self, other: &Self) -> Option<u24>

Adds two numbers, checking for overflow. If overflow happens, None is returned.
Source§

impl CheckedDiv for u24

Source§

fn checked_div(&self, other: &Self) -> Option<u24>

Divides two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned.
Source§

impl CheckedMul for u24

Source§

fn checked_mul(&self, other: &Self) -> Option<u24>

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned.
Source§

impl CheckedSub for u24

Source§

fn checked_sub(&self, other: &Self) -> Option<u24>

Subtracts two numbers, checking for underflow. If underflow happens, None is returned.
Source§

impl Clone for u24

Source§

fn clone(&self) -> u24

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 ConstOne for u24

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl ConstZero for u24

Source§

const ZERO: Self = u24::MIN

The additive identity element of Self, 0.
Source§

impl Debug for u24

Source§

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

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

impl Default for u24

Source§

fn default() -> u24

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

impl Display for u24

Source§

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

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

impl Div<&u24> for &u24

Source§

type Output = u24

The resulting type after applying the / operator.
Source§

fn div(self, other: &u24) -> u24

Performs the / operation. Read more
Source§

impl Div<&u24> for u24

Source§

type Output = u24

The resulting type after applying the / operator.
Source§

fn div(self, other: &u24) -> Self

Performs the / operation. Read more
Source§

impl Div<u24> for &u24

Source§

type Output = u24

The resulting type after applying the / operator.
Source§

fn div(self, other: u24) -> u24

Performs the / operation. Read more
Source§

impl Div for u24

Source§

type Output = u24

The resulting type after applying the / operator.
Source§

fn div(self, other: u24) -> Self

Performs the / operation. Read more
Source§

impl DivAssign<&u24> for u24

Source§

fn div_assign(&mut self, rhs: &u24)

Performs the /= operation. Read more
Source§

impl DivAssign for u24

Source§

fn div_assign(&mut self, rhs: u24)

Performs the /= operation. Read more
Source§

impl FromPrimitive for u24

Source§

fn from_i64(n: i64) -> Option<Self>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u64(n: u64) -> Option<Self>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i32(n: i32) -> Option<Self>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i128(n: i128) -> Option<Self>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u32(n: u32) -> Option<Self>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u128(n: u128) -> Option<Self>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

impl IntoBytes for u24
where [u8; 3]: IntoBytes, ZeroByte: IntoBytes, (): PaddingFree<Self, { _ }>,

Source§

fn as_bytes(&self) -> &[u8]
where Self: Immutable,

Gets the bytes of this value. Read more
Source§

fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to dst. Read more
Source§

fn write_to_prefix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the prefix of dst. Read more
Source§

fn write_to_suffix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the suffix of dst. Read more
Source§

impl Mul<&u24> for &u24

Source§

type Output = u24

The resulting type after applying the * operator.
Source§

fn mul(self, other: &u24) -> u24

Performs the * operation. Read more
Source§

impl Mul<&u24> for u24

Source§

type Output = u24

The resulting type after applying the * operator.
Source§

fn mul(self, other: &u24) -> Self

Performs the * operation. Read more
Source§

impl Mul<u24> for &u24

Source§

type Output = u24

The resulting type after applying the * operator.
Source§

fn mul(self, other: u24) -> u24

Performs the * operation. Read more
Source§

impl Mul for u24

Source§

type Output = u24

The resulting type after applying the * operator.
Source§

fn mul(self, other: u24) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<&u24> for u24

Source§

fn mul_assign(&mut self, rhs: &u24)

Performs the *= operation. Read more
Source§

impl MulAssign for u24

Source§

fn mul_assign(&mut self, rhs: u24)

Performs the *= operation. Read more
Source§

impl Not for u24

Source§

type Output = u24

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Num for u24

Source§

type FromStrRadixErr = ParseU24Err

Source§

fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
Source§

impl NumCast for u24

Source§

fn from<T: ToPrimitive>(n: T) -> Option<Self>

Creates a number from another value that can be converted into a primitive via the ToPrimitive trait. If the source value cannot be represented by the target type, then None is returned. Read more
Source§

impl One for u24

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl Ord for u24

Source§

fn cmp(&self, other: &Self) -> 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<i16> for u24

Source§

fn eq(&self, other: &i16) -> 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 PartialEq<i32> for u24

Source§

fn eq(&self, other: &i32) -> 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 PartialEq<i64> for u24

Source§

fn eq(&self, other: &i64) -> 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 PartialEq<i8> for u24

Source§

fn eq(&self, other: &i8) -> 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 PartialEq<u16> for u24

Source§

fn eq(&self, other: &u16) -> 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 PartialEq<u32> for u24

Source§

fn eq(&self, other: &u32) -> 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 PartialEq<u64> for u24

Source§

fn eq(&self, other: &u64) -> 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 PartialEq<u8> for u24

Source§

fn eq(&self, other: &u8) -> 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 PartialEq<usize> for u24

Source§

fn eq(&self, other: &usize) -> 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 PartialEq for u24

Source§

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

Source§

fn partial_cmp(&self, other: &i16) -> 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 PartialOrd<i32> for u24

Source§

fn partial_cmp(&self, other: &i32) -> 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 PartialOrd<i64> for u24

Source§

fn partial_cmp(&self, other: &i64) -> 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 PartialOrd<i8> for u24

Source§

fn partial_cmp(&self, other: &i8) -> 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 PartialOrd<u16> for u24

Source§

fn partial_cmp(&self, other: &u16) -> 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 PartialOrd<u32> for u24

Source§

fn partial_cmp(&self, other: &u32) -> 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 PartialOrd<u64> for u24

Source§

fn partial_cmp(&self, other: &u64) -> 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 PartialOrd<u8> for u24

Source§

fn partial_cmp(&self, other: &u8) -> 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 PartialOrd<usize> for u24

Source§

fn partial_cmp(&self, other: &usize) -> 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 PartialOrd for u24

Source§

fn partial_cmp(&self, other: &Self) -> 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 PrimInt for u24

Source§

fn count_ones(self) -> u32

Returns the number of ones in the binary representation of self. Read more
Source§

fn count_zeros(self) -> u32

Returns the number of zeros in the binary representation of self. Read more
Source§

fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self. Read more
Source§

fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation of self. Read more
Source§

fn rotate_left(self, n: u32) -> Self

Shifts the bits to the left by a specified amount, n, wrapping the truncated bits to the end of the resulting integer. Read more
Source§

fn rotate_right(self, n: u32) -> Self

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer. Read more
Source§

fn signed_shl(self, n: u32) -> Self

Shifts the bits to the left by a specified amount, n, filling zeros in the least significant bits. Read more
Source§

fn signed_shr(self, n: u32) -> Self

Shifts the bits to the right by a specified amount, n, copying the “sign bit” in the most significant bits even for unsigned types. Read more
Source§

fn unsigned_shl(self, n: u32) -> Self

Shifts the bits to the left by a specified amount, n, filling zeros in the least significant bits. Read more
Source§

fn unsigned_shr(self, n: u32) -> Self

Shifts the bits to the right by a specified amount, n, filling zeros in the most significant bits. Read more
Source§

fn swap_bytes(self) -> Self

Reverses the byte order of the integer. Read more
Source§

fn from_be(x: Self) -> Self

Convert an integer from big endian to the target’s endianness. Read more
Source§

fn from_le(x: Self) -> Self

Convert an integer from little endian to the target’s endianness. Read more
Source§

fn to_be(self) -> Self

Convert self to big endian from the target’s endianness. Read more
Source§

fn to_le(self) -> Self

Convert self to little endian from the target’s endianness. Read more
Source§

fn pow(self, exp: u32) -> Self

Raises self to the power of exp, using exponentiation by squaring. Read more
Source§

fn leading_ones(self) -> u32

Returns the number of leading ones in the binary representation of self. Read more
Source§

fn trailing_ones(self) -> u32

Returns the number of trailing ones in the binary representation of self. Read more
Source§

fn reverse_bits(self) -> Self

Reverses the order of bits in the integer. Read more
Source§

impl Rem<&u24> for &u24

Source§

type Output = u24

The resulting type after applying the % operator.
Source§

fn rem(self, other: &u24) -> u24

Performs the % operation. Read more
Source§

impl Rem<&u24> for u24

Source§

type Output = u24

The resulting type after applying the % operator.
Source§

fn rem(self, other: &u24) -> Self

Performs the % operation. Read more
Source§

impl Rem<u24> for &u24

Source§

type Output = u24

The resulting type after applying the % operator.
Source§

fn rem(self, other: u24) -> u24

Performs the % operation. Read more
Source§

impl Rem for u24

Source§

type Output = u24

The resulting type after applying the % operator.
Source§

fn rem(self, other: u24) -> Self

Performs the % operation. Read more
Source§

impl RemAssign<&u24> for u24

Source§

fn rem_assign(&mut self, rhs: &u24)

Performs the %= operation. Read more
Source§

impl RemAssign for u24

Source§

fn rem_assign(&mut self, rhs: u24)

Performs the %= operation. Read more
Source§

impl Saturating for u24

Source§

fn saturating_add(self, v: Self) -> Self

Saturating addition operator. Returns a+b, saturating at the numeric bounds instead of overflowing.
Source§

fn saturating_sub(self, v: Self) -> Self

Saturating subtraction operator. Returns a-b, saturating at the numeric bounds instead of overflowing.
Source§

impl SaturatingAdd for u24

Source§

fn saturating_add(&self, other: &Self) -> u24

Saturating addition. Computes self + other, saturating at the relevant high or low boundary of the type.
Source§

impl SaturatingMul for u24

Source§

fn saturating_mul(&self, other: &Self) -> u24

Saturating multiplication. Computes self * other, saturating at the relevant high or low boundary of the type.
Source§

impl SaturatingSub for u24

Source§

fn saturating_sub(&self, other: &Self) -> u24

Saturating subtraction. Computes self - other, saturating at the relevant high or low boundary of the type.
Source§

impl Shl<usize> for u24

Source§

type Output = u24

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

fn shl(self, rhs: usize) -> Self::Output

Performs the << operation. Read more
Source§

impl Shr<usize> for u24

Source§

type Output = u24

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

fn shr(self, rhs: usize) -> Self::Output

Performs the >> operation. Read more
Source§

impl Sub<&u24> for &u24

Source§

type Output = u24

The resulting type after applying the - operator.
Source§

fn sub(self, other: &u24) -> u24

Performs the - operation. Read more
Source§

impl Sub<&u24> for u24

Source§

type Output = u24

The resulting type after applying the - operator.
Source§

fn sub(self, other: &u24) -> Self

Performs the - operation. Read more
Source§

impl Sub<u24> for &u24

Source§

type Output = u24

The resulting type after applying the - operator.
Source§

fn sub(self, other: u24) -> u24

Performs the - operation. Read more
Source§

impl Sub for u24

Source§

type Output = u24

The resulting type after applying the - operator.
Source§

fn sub(self, other: u24) -> Self

Performs the - operation. Read more
Source§

impl SubAssign<&u24> for u24

Source§

fn sub_assign(&mut self, rhs: &u24)

Performs the -= operation. Read more
Source§

impl SubAssign for u24

Source§

fn sub_assign(&mut self, rhs: u24)

Performs the -= operation. Read more
Source§

impl ToPrimitive for u24

Source§

fn to_i64(&self) -> Option<i64>

Converts the value of self to an i64. If the value cannot be represented by an i64, then None is returned.
Source§

fn to_u64(&self) -> Option<u64>

Converts the value of self to a u64. If the value cannot be represented by a u64, then None is returned.
Source§

fn to_u32(&self) -> Option<u32>

Converts the value of self to a u32. If the value cannot be represented by a u32, then None is returned.
Source§

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize. If the value cannot be represented by an isize, then None is returned.
Source§

fn to_i8(&self) -> Option<i8>

Converts the value of self to an i8. If the value cannot be represented by an i8, then None is returned.
Source§

fn to_i16(&self) -> Option<i16>

Converts the value of self to an i16. If the value cannot be represented by an i16, then None is returned.
Source§

fn to_i32(&self) -> Option<i32>

Converts the value of self to an i32. If the value cannot be represented by an i32, then None is returned.
Source§

fn to_i128(&self) -> Option<i128>

Converts the value of self to an i128. If the value cannot be represented by an i128 (i64 under the default implementation), then None is returned. Read more
Source§

fn to_usize(&self) -> Option<usize>

Converts the value of self to a usize. If the value cannot be represented by a usize, then None is returned.
Source§

fn to_u8(&self) -> Option<u8>

Converts the value of self to a u8. If the value cannot be represented by a u8, then None is returned.
Source§

fn to_u16(&self) -> Option<u16>

Converts the value of self to a u16. If the value cannot be represented by a u16, then None is returned.
Source§

fn to_u128(&self) -> Option<u128>

Converts the value of self to a u128. If the value cannot be represented by a u128 (u64 under the default implementation), then None is returned. Read more
Source§

fn to_f32(&self) -> Option<f32>

Converts the value of self to an f32. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f32.
Source§

fn to_f64(&self) -> Option<f64>

Converts the value of self to an f64. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f64. Read more
Source§

impl TryFromBytes for u24
where [u8; 3]: TryFromBytes, ZeroByte: TryFromBytes,

Source§

fn try_read_from_bytes( source: &[u8], ) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read the given source as a Self. Read more
Source§

fn try_read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the prefix of the given source. Read more
Source§

fn try_read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the suffix of the given source. Read more
Source§

impl Zero for u24

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl Copy for u24

Source§

impl Eq for u24

Source§

impl Immutable for u24
where [u8; 3]: Immutable, ZeroByte: Immutable,

Source§

impl StructuralPartialEq for u24

Source§

impl Unsigned for u24

Auto Trait Implementations§

§

impl Freeze for u24

§

impl RefUnwindSafe for u24

§

impl Send for u24

§

impl Sync for u24

§

impl Unpin for u24

§

impl UnwindSafe for u24

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> LowerBounded for T
where T: Bounded,

Source§

fn min_value() -> T

Returns the smallest finite number this type can represent
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.
Source§

impl<T> UpperBounded for T
where T: Bounded,

Source§

fn max_value() -> T

Returns the largest finite number this type can represent
Source§

impl<T> NumAssign for T
where T: Num + NumAssignOps,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T> NumAssignRef for T
where T: NumAssign + for<'r> NumAssignOps<&'r T>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T> NumRef for T
where T: Num + for<'r> NumOps<&'r T>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,