pub struct Conversion { /* private fields */ }Expand description
A value with a known source unit, ready to convert.
Implementations§
Source§impl Conversion
impl Conversion
Sourcepub fn to(&self, unit: &str) -> Result<f64, Error>
pub fn to(&self, unit: &str) -> Result<f64, Error>
Convert to the destination unit.
§Errors
Returns Error::UnsupportedUnit if unit is unknown, or
Error::IncompatibleMeasures if it measures something different from the source.
Sourcepub fn to_best(&self) -> Option<Best>
pub fn to_best(&self) -> Option<Best>
Convert to the most appropriate unit (the smallest value ≥ 1 in the source system).
Sourcepub fn to_best_with(&self, exclude: &[&str], cut_off: f64) -> Option<Best>
pub fn to_best_with(&self, exclude: &[&str], cut_off: f64) -> Option<Best>
Like to_best, excluding units in exclude and using cut_off
as the lower bound a candidate value must reach.
Sourcepub fn possibilities(&self) -> Vec<&'static str>
pub fn possibilities(&self) -> Vec<&'static str>
The unit abbreviations the source value can be converted to (its measure’s units).
Sourcepub fn describe_origin(&self) -> UnitInfo
pub fn describe_origin(&self) -> UnitInfo
Metadata about the source unit.
Trait Implementations§
Source§impl Clone for Conversion
impl Clone for Conversion
Source§fn clone(&self) -> Conversion
fn clone(&self) -> Conversion
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Conversion
Auto Trait Implementations§
impl Freeze for Conversion
impl RefUnwindSafe for Conversion
impl Send for Conversion
impl Sync for Conversion
impl Unpin for Conversion
impl UnsafeUnpin for Conversion
impl UnwindSafe for Conversion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more