units::unit::catalogue
The unit catalogue: SI base and derived units, units accepted with the SI, and common other units with their NIST SP 811 factors (exact where the definition is exact). Parsing and the error suggestions read it.
Structs
EntrySource
pub struct EntryOne unit of the catalogue.
nabi
let ft = units::unit::catalogue::find("ft") ?? panic("ft");
assert(ft.scale == 0.3048 && ft.name == "foot");
The symbol (
"ft").The singular name (
"foot").The plural name (
"feet").One of the unit in coherent SI units.
The SI value of zero of the unit (temperature scales only).
The dimension.
Whether SI prefixes apply (
km,kilometre).
Functions
entriesSource
pub fn entries() -> List<Entry> Every unit of the catalogue, without prefixed forms.
nabi
let all = units::unit::catalogue::entries();
assert(all.iter().any(|e: units::unit::catalogue::Entry| e.symbol == "psi"));
findSource
pub fn find(text: str) -> Entry | none The catalogue unit written text: its symbol ("ft"), its name or
plural ("foot", "feet", any case), or a common other spelling
("meter", "°C", "in"). No prefixes; DynUnit::parse adds them.
nabi
use units::unit::catalogue::find;
assert((find("Feet") ?? panic("feet")).symbol == "ft");
assert((find("°C") ?? panic("degC")).offset == 273.15);
assert((find("Degrees Fahrenheit") ?? panic("degF")).symbol == "degF");
assert(find("km") == none);