pub struct Value {
pub magnitude: f64,
pub si_units_num: Vec<SiUnit>,
pub si_units_den: Vec<SiUnit>,
}Expand description
Struct that represents a value with units
Fields§
§magnitude: f64Magnitude of Value
si_units_num: Vec<SiUnit>Numerator
si_units_den: Vec<SiUnit>Denominator
Implementations§
Source§impl Value
impl Value
Sourcepub fn same(&self, other: &Value) -> bool
pub fn same(&self, other: &Value) -> bool
checks if two Values are the same
let v1 = DerivedUnits::Hertz.get_value();
let v2 = DerivedUnits::Newtons.get_value();
assert_eq!(v1.same(v2),False);Sourcepub fn set_magnitude(self, new_mag: f64) -> Self
pub fn set_magnitude(self, new_mag: f64) -> Self
sets magnitude of Value struct
let v1 = DerivedUnits::Hertz.get_value().set_magnitude(50);
println!("{}",v1);Sourcepub fn add_num(self, unit: SiUnit) -> Self
pub fn add_num(self, unit: SiUnit) -> Self
Adds a unit to the numerator
let v1 = DerivedUnits::Hertz.get_value().add_num(SiUnit::Kilogram);
println!("{}",v1);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
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