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) -> Number
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>
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
impl<I> FunctionResult for Number
where
I: Into<Value>,
fn into_result(self) -> TeraResult<Value>
impl<T> Any for Number
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Number
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Number
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Number
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Number
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Number
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for Number
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for Number
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Number
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Number
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>