pub struct Unit {
pub dimension: Dimension,
pub scale: f64,
pub offset: f64,
}Expand description
A unit: its dimension and the affine map to the coherent SI unit of that
dimension, value_in_si = value · scale + offset.
Fields§
§dimension: DimensionThe physical dimension.
scale: f64Size of one unit in coherent SI units (> 0).
offset: f64SI value of the unit’s zero (0 except for scales such as Cel).
Implementations§
Source§impl Unit
impl Unit
Sourcepub fn convert_to(&self, value: f64, to: &Unit) -> Result<f64, UnitError>
pub fn convert_to(&self, value: f64, to: &Unit) -> Result<f64, UnitError>
A reading value in this unit, in to.
§Errors
UnitError::NotFinite for value, UnitError::DimensionMismatch
when to measures something else.
Trait Implementations§
impl Copy for Unit
impl StructuralPartialEq for Unit
Auto Trait Implementations§
impl Freeze for Unit
impl RefUnwindSafe for Unit
impl Send for Unit
impl Sync for Unit
impl Unpin for Unit
impl UnsafeUnpin for Unit
impl UnwindSafe for Unit
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