pub struct ValueUnit {
pub value: f64,
/* private fields */
}Expand description
Allways use the ValueUnit macro to create this struct.
This struct implements all basic arithmatic methods and a power method.
It should be noted however that add, subtract, addassign and subassign will panic if the units are not identical.
Use try_add and try_sub if you want a Result.
root will also panic if not all units have a power which is a multiple of the power.
use value_unit::*;
let d = ValueUnit!(10 m);
let t = ValueUnit!(5 s);
assert_eq!(d.try_add(&t), Err("Units m and s don't match".to_string()));Fields§
§value: f64Implementations§
Trait Implementations§
Source§impl AddAssign<&ValueUnit> for ValueUnit
impl AddAssign<&ValueUnit> for ValueUnit
Source§fn add_assign(&mut self, other: &ValueUnit)
fn add_assign(&mut self, other: &ValueUnit)
Performs the
+= operation. Read moreSource§impl AddAssign for ValueUnit
impl AddAssign for ValueUnit
Source§fn add_assign(&mut self, other: ValueUnit)
fn add_assign(&mut self, other: ValueUnit)
Performs the
+= operation. Read moreimpl StructuralPartialEq for ValueUnit
Auto Trait Implementations§
impl Freeze for ValueUnit
impl RefUnwindSafe for ValueUnit
impl Send for ValueUnit
impl Sync for ValueUnit
impl Unpin for ValueUnit
impl UnwindSafe for ValueUnit
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