Enum Number
#[non_exhaustive]
pub enum Number
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
impl Number
fn is_float(&self) -> boolIs the number a float?
fn is_integer(&self) -> boolIs the number an integer? Does not check whether the float could be converted to an integer losslessly, just checks the type.
fn as_float(&self) -> f64Converts a number to a float.
fn as_integer(&self) -> Option<i128>Tries to convert a number to a i128.
Trait Implementations
impl Clone for Number
fn clone(&self) -> Self
impl Copy for Number
impl Debug for Number
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Display for Number
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl PartialEq for Number
fn eq(&self, other: &Self) -> bool
impl PartialOrd for Number
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
impl<'k> ArgFromValue<'k> for Number
type Output = Number;fn from_value(value: &'k Value) -> TeraResult<Self::Output>