pub struct Conversion {
pub source_unit: String,
pub calculation: Calculation,
pub target_unit: String,
}Expand description
Conversion defines the relationship of two units so that source_unit = rate * target_unit. E.g. kg=1000g
Fields§
§source_unit: String§calculation: Calculation§target_unit: StringImplementations§
Source§impl Conversion
impl Conversion
Sourcepub fn new(
source_unit: &str,
calculation: Calculation,
target_unit: &str,
) -> Conversion
pub fn new( source_unit: &str, calculation: Calculation, target_unit: &str, ) -> Conversion
Creates a new conversion with the given values.
Sourcepub fn invert(&self) -> Conversion
pub fn invert(&self) -> Conversion
Inverts the conversion by transposing the units and using the rate’s reciprocal. E.g. kg=1000g becomes g=0.001kg
Trait Implementations§
Source§impl PartialEq for Conversion
impl PartialEq 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 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