Skip to main content

conformable

Function conformable 

Source
pub fn conformable(expr: &str) -> Result<Vec<String>>
Expand description

Finds all unit definitions that are conformable with expr.

Parses expr into a Unit, then iterates over every DefinitionKind::Unit entry returned by list_definitions. Any entry whose name parses successfully and whose dimensions match those of expr is included in the result. The returned names are in alphabetical order.

§Errors

Returns Err(UnitsError) if expr itself cannot be parsed.

§Examples

let lengths = gnu_units::conformable("m")?;
assert!(lengths.contains(&"km".to_string()));