Struct rink_core::number::NumberParts[][src]

pub struct NumberParts {
    pub exact_value: Option<String>,
    pub approx_value: Option<String>,
    pub factor: Option<String>,
    pub divfactor: Option<String>,
    pub raw_unit: Option<Quantity>,
    pub unit: Option<String>,
    pub quantity: Option<String>,
    pub dimensions: Option<String>,
    pub raw_dimensions: Option<Quantity>,
}

Several stringified properties of a number which are useful for displaying it to a user.

Fields

exact_value: Option<String>

Present if the number can be concisely represented exactly. May be decimal, fraction, or scientific notation.

approx_value: Option<String>

Present if the number can’t be exactly concisely represented in decimal or scientific notation.

factor: Option<String>

Numerator factor by which the value is multiplied, if not one.

divfactor: Option<String>

Divisor factor, if not one.

raw_unit: Option<Quantity>

High-level unit decomposition, in format that can be manipulated.

unit: Option<String>

Higher-level unit decomposition, if available.

quantity: Option<String>

The physical quantity associated with the unit, if available.

dimensions: Option<String>

The dimensionality of the unit.

raw_dimensions: Option<Quantity>

Map of base units and their dimensions.

Implementations

impl NumberParts[src]

pub fn format(&self, pat: &str) -> String[src]

A DSL for formatting numbers.

  • a: Approximate numerical value, if exists.
  • e: Exact numerical value, if exists.
  • n: Exact and approximate values.
  • u: Unit.
  • q: Quantity, if exists.
  • w: Quantity in parentheses, if exists.
  • d: Dimensionality, if not same as unit.
  • D: Dimensionality, always.
  • p: Quantity and dimensionality in parentheses.

Display impl is equivalent to n u w.

Whitespace is compacted. Any unrecognized characters are passed through.

pub fn token_format<'a>(&'a self, pattern: &'a str) -> NumberPartsFmt<'a>[src]

A DSL for formatting numbers.

  • a: Approximate numerical value, if exists.
  • e: Exact numerical value, if exists.
  • n: Exact and approximate values.
  • u: Unit.
  • q: Quantity, if exists.
  • w: Quantity in parentheses, if exists.
  • d: Dimensionality, if not same as unit.
  • D: Dimensionality, always.
  • p: Quantity and dimensionality in parentheses.

Display impl is equivalent to n u w.

Whitespace is compacted. Any unrecognized characters are passed through.

Trait Implementations

impl Clone for NumberParts[src]

impl Debug for NumberParts[src]

impl Default for NumberParts[src]

impl<'de> Deserialize<'de> for NumberParts[src]

impl Display for NumberParts[src]

impl Serialize for NumberParts[src]

impl<'a> TokenFmt<'a> for NumberParts[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.