Struct rink_core::context::Context[][src]

pub struct Context {
Show 19 fields pub dimensions: BTreeSet<Dimension>, pub canonicalizations: BTreeMap<String, String>, pub units: BTreeMap<String, Number>, pub quantities: BTreeMap<Quantity, String>, pub reverse: BTreeMap<Quantity, String>, pub prefixes: Vec<(String, Number)>, pub definitions: BTreeMap<String, Expr>, pub docs: BTreeMap<String, String>, pub categories: BTreeMap<String, String>, pub category_names: BTreeMap<String, String>, pub datepatterns: Vec<Vec<DatePattern>>, pub substances: BTreeMap<String, Substance>, pub substance_symbols: BTreeMap<String, String>, pub temporaries: BTreeMap<String, Number>, pub now: DateTime<Local>, pub short_output: bool, pub use_humanize: bool, pub save_previous_result: bool, pub previous_result: Option<Number>,
}
Expand description

The evaluation context that contains unit definitions.

Fields

dimensions: BTreeSet<Dimension>canonicalizations: BTreeMap<String, String>units: BTreeMap<String, Number>quantities: BTreeMap<Quantity, String>reverse: BTreeMap<Quantity, String>prefixes: Vec<(String, Number)>definitions: BTreeMap<String, Expr>docs: BTreeMap<String, String>categories: BTreeMap<String, String>category_names: BTreeMap<String, String>datepatterns: Vec<Vec<DatePattern>>substances: BTreeMap<String, Substance>substance_symbols: BTreeMap<String, String>temporaries: BTreeMap<String, Number>now: DateTime<Local>short_output: booluse_humanize: boolsave_previous_result: boolprevious_result: Option<Number>

Implementations

Creates a new, empty context

Given a unit name, returns its value if it exists. Supports SI prefixes, plurals, bare dimensions like length, and quantities.

Given a unit name, try to return a canonical name (expanding aliases and such)

Describes a value’s unit, gives true if the unit is reciprocal (e.g. you should prefix “1.0 / “ or replace “multiply” with “divide” when rendering it).

Evaluates an expression to compute its value, excluding -> conversions.

Evaluates an expression, include -> conversions.

Takes a parsed definitions.units from gnu_units::parse(). Prints if there are errors in the file.

Trait Implementations

Formats the value using the given formatter. Read more

Equivalent to Context::new()

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 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.