pub struct Unit { /* private fields */ }Expand description
Represents a dimensional quantity: a numeric factor paired with zero or more base dimensions.
Implementations§
Source§impl Unit
impl Unit
Sourcepub fn parse(input: &str) -> Result<Self>
pub fn parse(input: &str) -> Result<Self>
Parses a GNU units expression string and returns the resulting Unit.
Sourcepub fn base_units(&self) -> String
pub fn base_units(&self) -> String
Returns the base dimensions as a human-readable string.
Sourcepub fn pow(&mut self, power: i32) -> Result<()>
pub fn pow(&mut self, power: i32) -> Result<()>
Raises self to a non-negative integer power in place.
Sourcepub fn convert_to(self, to: Unit) -> Result<f64>
pub fn convert_to(self, to: Unit) -> Result<f64>
Converts self into the unit expressed by to, returning the numeric
conversion factor.
Sourcepub fn is_conformable(&self, other: &Unit) -> bool
pub fn is_conformable(&self, other: &Unit) -> bool
Returns true when self and other have the same base dimensions.
Trait Implementations§
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