pub struct Myth16(/* private fields */);Expand description
§16bit measurement type
A type to calculate lossless dimensions with a fixed 4 digit precision.
All sizes are defined in the tenth fraction of μ:
10= 1 μ10_000= 1 mm30_000= 3 mm
The standard Display::fmt-method represents the value in mm. The alternate Display
shows the i16 value.
As 10_000 = 1 mm
§Warning
Casting an i64 into a Myth16 can cause an IntegerOverflow-error similar to casting
a big i64-value into an i16. It’s up to the programmer to omit these situation.
If your sizes can exceed 3 mm, than this type is not for you. Again:
⚠ Don’t try to store more then +/- 3 millimeter in a Myth16.
§Example:
let myth = Myth16::from(1.5);
assert_eq!(format!("{myth}"), "1.5");
assert_eq!(format!("{myth:.2}"), "1.50");
assert_eq!(format!("{myth:.4}"),"1.5000");
assert_eq!(format!("{myth:#}"), "15000");Implementations§
Source§impl Myth16
impl Myth16
pub const MIN: Myth16
pub const MAX: Myth16
pub const MM: Myth16
please use ONE instead.
Sourcepub fn as_mm(&self) -> f64
👎Deprecated since 1.0.3: please use as_f64 instead.
pub fn as_mm(&self) -> f64
please use as_f64 instead.
Returns the value as a f64 in “mm”.
Sourcepub fn floor(&self, unit: Unit) -> Self
pub fn floor(&self, unit: Unit) -> Self
Finds the nearest value less than or equal to an integer multiple of the given Unit.
Sourcepub const fn abs_diff(self, other: Myth16) -> Self
pub const fn abs_diff(self, other: Myth16) -> Self
Computes the absolute difference between self and other.
Sourcepub const fn signum(self) -> Self
pub const fn signum(self) -> Self
Returns a Myth16 representing the sign of self.
- 0 if the number is zero
- 1 if the number is positive
- -1 if the number is negative
Sourcepub const fn is_negative(&self) -> bool
pub const fn is_negative(&self) -> bool
Returns true if self is negative and false if zero or positive.
Sourcepub const fn is_positive(&self) -> bool
pub const fn is_positive(&self) -> bool
Returns true if self is positive and false if zero or negative.
Sourcepub const fn to_be_bytes(&self) -> [u8; 2]
pub const fn to_be_bytes(&self) -> [u8; 2]
Returns the memory representation of this Myth16 as a byte array in big-endian (network) byte order.
Sourcepub const fn to_le_bytes(&self) -> [u8; 2]
pub const fn to_le_bytes(&self) -> [u8; 2]
Returns the memory representation of this Myth16 as a byte array in little-endian byte order.
Sourcepub const fn to_ne_bytes(&self) -> [u8; 2]
pub const fn to_ne_bytes(&self) -> [u8; 2]
Returns the memory representation of this Myth16 as a byte array in native byte order.
Sourcepub const fn from_be_bytes(bytes: [u8; 2]) -> Self
pub const fn from_be_bytes(bytes: [u8; 2]) -> Self
Creates a Myth16 value from its representation as a byte array in big-endian.
Sourcepub const fn from_le_bytes(bytes: [u8; 2]) -> Self
pub const fn from_le_bytes(bytes: [u8; 2]) -> Self
Creates a Myth16 value from its representation as a byte array in little endian.
Sourcepub const fn from_ne_bytes(bytes: [u8; 2]) -> Self
pub const fn from_ne_bytes(bytes: [u8; 2]) -> Self
Creates a Myth16 value from its representation as a byte array in native byte order.
Trait Implementations§
Source§impl AddAssign<Myth16> for T64
impl AddAssign<Myth16> for T64
Source§fn add_assign(&mut self, other: Myth16)
fn add_assign(&mut self, other: Myth16)
+= operation. Read moreSource§impl AddAssign for Myth16
impl AddAssign for Myth16
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+= operation. Read moreSource§impl From<i32> for Myth16
A potentially dangerous function.
Use it for creating Myth16 in tests or where you can control the danger.
impl From<i32> for Myth16
A potentially dangerous function.
Use it for creating Myth16 in tests or where you can control the danger.
Source§impl Ord for Myth16
impl Ord for Myth16
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Myth16
impl PartialOrd for Myth16
Source§impl SubAssign<Myth16> for T64
impl SubAssign<Myth16> for T64
Source§fn sub_assign(&mut self, other: Myth16)
fn sub_assign(&mut self, other: Myth16)
-= operation. Read moreSource§impl SubAssign for Myth16
impl SubAssign for Myth16
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-= operation. Read more