Struct friendly::quantity::Quantity[][src]

pub struct Quantity<Q: QVal, F: PrefixFamily> { /* fields omitted */ }
Expand description

A numeric quantity to display.

Quantity is the core type for general display of numeric quantities that may be rescaled with prefixes, may have unit suffixes, etc.

By default, quantities are displayed with 4 significant figures and are auto-scaled. Individual convenience functions may provide different defaults.

Implementations

Create a new auto-scaled decimal quantity.

Create a new auto-scaled binary quantity.

Create a new auto-scaled quantity of arbitrary prefix type.

Configure this quantity with a different scale.

The use of Into bounds allows this to rescale with either a fixed scale:

let q = Quantity::decimal(10324);
let q = q.scale(Decimal::KILO);
assert_eq!(q.to_string().as_str(), "10.32 k");

Or auto-scaling:

let q = Quantity::decimal(10324);
let q = q.scale(Decimal::AUTO);
assert_eq!(q.to_string().as_str(), "10.32 k");

Change the unit suffix on this quantity.

Change whether to include a space before units.

Change the significant figures on this quantity.

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

Formats the value using the given formatter. 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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. 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.