pub enum Number {
Integer(i128),
Float(f64),
}Expand description
Simpler representation of numbers so operations are simpler to handle Also can be used for custom filters/tests/fn when you want to ensure you get a number
Variants§
Integer(i128)
Integers are stored in i128, which means we can’t use numbers from u128 above i128::MAX for math, which is probably ok for a template engine.
Float(f64)
Implementations§
Source§impl Number
impl Number
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Is the number an integer? Does not check whether the float could be converted to an integer losslessly, just checks the type.
Sourcepub fn as_integer(&self) -> Option<i128>
pub fn as_integer(&self) -> Option<i128>
Tries to convert a number to a i128.
Trait Implementations§
impl Copy 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 UnsafeUnpin 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