[−][src]Enum number_prefix::NumberPrefix
The result of trying to apply a prefix to a floating-point value.
Variants
Standalone(F)
A standalone value is returned when the number is too small to have any prefixes applied to it. This is commonly a special case, so is handled separately.
Prefixed(Prefix, F)
A prefixed value is large enough for prefixes. This holds the prefix, as well as the resulting value.
Methods
impl<F: Amounts> NumberPrefix<F>
[src]
pub fn decimal(amount: F) -> Self
[src]
Formats the given floating-point number using decimal prefixes.
This function accepts both f32
and f64
values. If you’re trying to
format an integer, you’ll have to cast it first.
Examples
use number_prefix::{Prefix, NumberPrefix}; assert_eq!(NumberPrefix::decimal(1_000_000_000_f32), NumberPrefix::Prefixed(Prefix::Giga, 1_f32));
pub fn binary(amount: F) -> Self
[src]
Formats the given floating-point number using binary prefixes.
This function accepts both f32
and f64
values. If you’re trying to
format an integer, you’ll have to cast it first.
Examples
use number_prefix::{Prefix, NumberPrefix}; assert_eq!(NumberPrefix::binary(1_073_741_824_f64), NumberPrefix::Prefixed(Prefix::Gibi, 1_f64));
Trait Implementations
impl<F: PartialEq> PartialEq<NumberPrefix<F>> for NumberPrefix<F>
[src]
fn eq(&self, other: &NumberPrefix<F>) -> bool
[src]
fn ne(&self, other: &NumberPrefix<F>) -> bool
[src]
impl<F: Clone> Clone for NumberPrefix<F>
[src]
fn clone(&self) -> NumberPrefix<F>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<F: Eq> Eq for NumberPrefix<F>
[src]
impl<F: Debug> Debug for NumberPrefix<F>
[src]
Auto Trait Implementations
impl<F> Send for NumberPrefix<F> where
F: Send,
F: Send,
impl<F> Sync for NumberPrefix<F> where
F: Sync,
F: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,