pub struct UnitSpec {
pub domain: UnitDomain,
pub quantity: &'static str,
pub symbol: &'static str,
pub scale_to_base: f64,
}Expand description
Small copyable unit descriptor for simple linear conversions.
Fields§
§domain: UnitDomain§quantity: &'static str§symbol: &'static str§scale_to_base: f64Implementations§
Source§impl UnitSpec
impl UnitSpec
Sourcepub const fn new(
domain: UnitDomain,
quantity: &'static str,
symbol: &'static str,
scale_to_base: f64,
) -> Self
pub const fn new( domain: UnitDomain, quantity: &'static str, symbol: &'static str, scale_to_base: f64, ) -> Self
Creates a new unit descriptor.
Sourcepub fn is_compatible_with(self, other: Self) -> bool
pub fn is_compatible_with(self, other: Self) -> bool
Returns whether two units can be converted with a linear scale factor.
Sourcepub fn convert_value(self, value: f64, target: Self) -> Option<f64>
pub fn convert_value(self, value: f64, target: Self) -> Option<f64>
Converts a value into a compatible target unit.
Trait Implementations§
impl Copy for UnitSpec
impl StructuralPartialEq for UnitSpec
Auto Trait Implementations§
impl Freeze for UnitSpec
impl RefUnwindSafe for UnitSpec
impl Send for UnitSpec
impl Sync for UnitSpec
impl Unpin for UnitSpec
impl UnsafeUnpin for UnitSpec
impl UnwindSafe for UnitSpec
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