pub enum BinaryPrefix<T> {
    Unity(T),
    Kibi(T),
    Mebi(T),
    Gibi(T),
    Tebi(T),
    Pebi(T),
    Exbi(T),
    Zebi(T),
    Yobi(T),
}
Expand description

Binary Prefixes (e.g. kibi, mebi).

Variants§

§

Unity(T)

x · 2⁰.

§

Kibi(T)

x · 2¹⁰.

§

Mebi(T)

x · 2²⁰.

§

Gibi(T)

x · 2³⁰.

§

Tebi(T)

x · 2⁴⁰.

§

Pebi(T)

x · 2⁵⁰.

§

Exbi(T)

x · 2⁶⁰.

§

Zebi(T)

x · 2⁷⁰.

§

Yobi(T)

x · 2⁸⁰.

Implementations§

source§

impl<T: Copy + Shl<Output = T> + Into<u128>> BinaryPrefix<T>

source

pub fn to_decimal_u128(&self) -> u128

Converts a Binary-Prefix value into a regular u128.

Returns

A u128.

Examples
use lib_rapid::compsci::unit_conversion::BinaryPrefix;
assert_eq!(5120u128, BinaryPrefix::Kibi(5u8).to_decimal_u128());
assert_eq!(5u128, BinaryPrefix::Unity(5u8).to_decimal_u128());
assert_eq!(1073741824u128, BinaryPrefix::Gibi(1u8).to_decimal_u128());

Trait Implementations§

source§

impl<T: Clone> Clone for BinaryPrefix<T>

source§

fn clone(&self) -> BinaryPrefix<T>

Returns a copy 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<T: Copy + Into<f64>> Into<f32> for BinaryPrefix<T>

Tests

use lib_rapid::compsci::unit_conversion::BinaryPrefix;
assert_eq!(3355443.2f32, BinaryPrefix::Mebi(3.2).into());
assert_eq!(4198.4f32, BinaryPrefix::Kibi(4.1).into());
source§

fn into(self) -> f32

Converts this type into the (usually inferred) input type.
source§

impl<T: Copy + Into<f64>> Into<f64> for BinaryPrefix<T>

Tests

use lib_rapid::compsci::unit_conversion::BinaryPrefix;
assert_eq!(3355443.2f64, BinaryPrefix::Mebi(3.2).into());
assert_eq!(4198.4f64, BinaryPrefix::Kibi(4.1).into());
source§

fn into(self) -> f64

Converts this type into the (usually inferred) input type.
source§

impl<T: Copy + Shl<Output = T> + Into<u128>> Into<u128> for BinaryPrefix<T>

Tests

use lib_rapid::compsci::unit_conversion::BinaryPrefix;
assert_eq!(3145728u128, BinaryPrefix::Mebi(3 as u128).into());
assert_eq!(4096u128, BinaryPrefix::Kibi(4 as u128).into());
source§

fn into(self) -> u128

Converts this type into the (usually inferred) input type.
source§

impl<T: PartialEq> PartialEq for BinaryPrefix<T>

source§

fn eq(&self, other: &BinaryPrefix<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Copy> Copy for BinaryPrefix<T>

source§

impl<T> StructuralPartialEq for BinaryPrefix<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for BinaryPrefix<T>
where T: RefUnwindSafe,

§

impl<T> Send for BinaryPrefix<T>
where T: Send,

§

impl<T> Sync for BinaryPrefix<T>
where T: Sync,

§

impl<T> Unpin for BinaryPrefix<T>
where T: Unpin,

§

impl<T> UnwindSafe for BinaryPrefix<T>
where T: UnwindSafe,

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> 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,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.