#[non_exhaustive]pub struct Unit { /* private fields */ }Expand description
A unit of measurement that includes a power.
Implementations§
Source§impl Unit
impl Unit
Sourcepub fn new(quantity: impl Into<Base>) -> Self
pub fn new(quantity: impl Into<Base>) -> Self
Creates a new unit with the given quantity, with power 1.
Sourcepub fn with_power(quantity: impl Into<Base>, power: i8) -> Self
pub fn with_power(quantity: impl Into<Base>, power: i8) -> Self
Creates a new unit with the given quantity and power.
Sourcepub fn conversion_factor(&self, target: Unit) -> Result<f64, ConversionError>
pub fn conversion_factor(&self, target: Unit) -> Result<f64, ConversionError>
If this unit can be converted to the target unit, returns the conversion factor between them.
Trait Implementations§
impl Copy for Unit
impl Eq for Unit
Source§impl From<Unit> for CompoundUnit
impl From<Unit> for CompoundUnit
Source§impl FromStr for Unit
Try a to convert a string to a Unit.
impl FromStr for Unit
Try a to convert a string to a Unit.
The string should be in the format <base>[^<power>], where <quantity> is the
abbreviation of the quantity (see Base), and <power> is a signed integer representing the
power of the unit. If <power> is not specified, it is assumed to be 1.
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