pub struct Dimension(pub [i8; 7]);Expand description
A dimensional exponent vector over the seven UCUM base quantities.
The exponent order is fixed and documented:
| index | quantity | base unit |
|---|---|---|
| 0 | length | m |
| 1 | time | s |
| 2 | mass | g |
| 3 | plane angle | rad |
| 4 | temperature | K |
| 5 | electric charge | C |
| 6 | luminous intensity | cd |
All arithmetic saturates at the i8 bounds rather than overflowing, so the
type can never panic, even on absurd inputs such as m120.m120.
use ucum::Dimension;
let area = Dimension::DIMENSIONLESS.mul(Dimension([2, 0, 0, 0, 0, 0, 0]));
assert_eq!(area, Dimension([2, 0, 0, 0, 0, 0, 0]));Tuple Fields§
§0: [i8; 7]Implementations§
Source§impl Dimension
impl Dimension
Sourcepub const DIMENSIONLESS: Dimension
pub const DIMENSIONLESS: Dimension
The dimensionless dimension (all exponents zero).
Sourcepub fn is_dimensionless(&self) -> bool
pub fn is_dimensionless(&self) -> bool
Returns true when every exponent is zero.
Sourcepub fn mul(self, other: Dimension) -> Dimension
pub fn mul(self, other: Dimension) -> Dimension
Multiplies two dimensions by adding their exponents (saturating).
Named mul per the public UCUM API contract; it intentionally does not
implement std::ops::Mul, to keep the type’s surface explicit.
Trait Implementations§
impl Copy for Dimension
impl Eq for Dimension
impl StructuralPartialEq for Dimension
Auto Trait Implementations§
impl Freeze for Dimension
impl RefUnwindSafe for Dimension
impl Send for Dimension
impl Sync for Dimension
impl Unpin for Dimension
impl UnsafeUnpin for Dimension
impl UnwindSafe for Dimension
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