pub enum Number {
Basic(BasicNumber),
Scientific(ScientificNumber),
}
Expand description
A Haystack number.
Variants§
Basic(BasicNumber)
Scientific(ScientificNumber)
Implementations§
Source§impl Number
impl Number
Sourcepub fn new(value: f64, unit: Option<String>) -> Self
pub fn new(value: f64, unit: Option<String>) -> Self
Create a new Number
. If present, the unit should
be a valid unit string from Project Haystack’s
unit database.
Sourcepub fn new_unitless(value: f64) -> Self
pub fn new_unitless(value: f64) -> Self
Create a new Number
and no unit.
Sourcepub fn new_scientific(
significand: f64,
exponent: i32,
unit: Option<String>,
) -> Option<Self>
pub fn new_scientific( significand: f64, exponent: i32, unit: Option<String>, ) -> Option<Self>
Create a new scientific notation Number
. If present, the unit should
be a valid unit string from Project Haystack’s
unit database.
Sourcepub fn new_scientific_unitless(significand: f64, exponent: i32) -> Option<Self>
pub fn new_scientific_unitless(significand: f64, exponent: i32) -> Option<Self>
Create a new scientific notation Number
and no unit.
Sourcepub fn as_number(&self) -> Option<&BasicNumber>
pub fn as_number(&self) -> Option<&BasicNumber>
If this represents a non-scientific notation number, return the number.
Sourcepub fn as_scientific_number(&self) -> Option<&ScientificNumber>
pub fn as_scientific_number(&self) -> Option<&ScientificNumber>
If this represents a number in scientific notation, return the scientific notation number.
Sourcepub fn to_axon_code(&self) -> String
pub fn to_axon_code(&self) -> String
Return a string containing Axon code representing this number.
Trait Implementations§
impl StructuralPartialEq for Number
Auto Trait Implementations§
impl Freeze for Number
impl RefUnwindSafe for Number
impl Send for Number
impl Sync for Number
impl Unpin for Number
impl UnwindSafe for Number
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