pub enum NumberPrefix<F> {
    Standalone(F),
    Prefixed(Prefix, F),
}
Expand description

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.

Implementations§

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));

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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.