pub struct Measurement<T> { /* private fields */ }Expand description
A value and the unit it represents.
Implementations§
Source§impl<T> Measurement<T>
impl<T> Measurement<T>
Sourcepub fn new(value: T, unit: impl Into<CompoundUnit>) -> Self
pub fn new(value: T, unit: impl Into<CompoundUnit>) -> Self
Create a new measurement.
Sourcepub fn unit(&self) -> &CompoundUnit
pub fn unit(&self) -> &CompoundUnit
Get the unit of this measurement.
Sourcepub fn convert(
&self,
target: impl Into<CompoundUnit>,
) -> Result<Self, ConversionError>
pub fn convert( &self, target: impl Into<CompoundUnit>, ) -> Result<Self, ConversionError>
Convert this measurement to another unit. Returns Err if the conversion is not
possible.
Auto Trait Implementations§
impl<T> Freeze for Measurement<T>where
T: Freeze,
impl<T> RefUnwindSafe for Measurement<T>where
T: RefUnwindSafe,
impl<T> Send for Measurement<T>where
T: Send,
impl<T> Sync for Measurement<T>where
T: Sync,
impl<T> Unpin for Measurement<T>where
T: Unpin,
impl<T> UnwindSafe for Measurement<T>where
T: UnwindSafe,
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