Enum lib_rapid::compsci::unit_conversion::BinaryPrefix
source · 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>
impl<T: Copy + Shl<Output = T> + Into<u128>> BinaryPrefix<T>
sourcepub fn to_decimal_u128(&self) -> u128
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>
impl<T: Clone> Clone for BinaryPrefix<T>
source§fn clone(&self) -> BinaryPrefix<T>
fn clone(&self) -> BinaryPrefix<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Copy + Into<f64>> Into<f32> for BinaryPrefix<T>
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§impl<T: Copy + Into<f64>> Into<f64> for BinaryPrefix<T>
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§impl<T: Copy + Shl<Output = T> + Into<u128>> Into<u128> for BinaryPrefix<T>
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§impl<T: PartialEq> PartialEq for BinaryPrefix<T>
impl<T: PartialEq> PartialEq for BinaryPrefix<T>
source§fn eq(&self, other: &BinaryPrefix<T>) -> bool
fn eq(&self, other: &BinaryPrefix<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<T: Copy> Copy for BinaryPrefix<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more