pub struct Number { /* private fields */ }
Expand description
Represents an HCL number.
Implementations§
Source§impl Number
impl Number
Sourcepub fn from_f64(f: f64) -> Option<Number>
pub fn from_f64(f: f64) -> Option<Number>
Creates a new Number
from a f64
. Returns None
if the float is infinite or NaN.
§Example
assert!(Number::from_f64(42.0).is_some());
assert!(Number::from_f64(f64::NAN).is_none());
assert!(Number::from_f64(f64::INFINITY).is_none());
assert!(Number::from_f64(f64::NEG_INFINITY).is_none());
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Represents the Number
as f64 if possible. Returns None otherwise.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
If the Number
is an integer, represent it as i64 if possible. Returns None otherwise.
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
If the Number
is an integer, represent it as u64 if possible. Returns None otherwise.
Sourcepub fn is_f64(&self) -> bool
pub fn is_f64(&self) -> bool
Returns true if the Number
is a float.
For any Number
on which is_f64
returns true, as_f64
is guaranteed to return the
float value.
Trait Implementations§
Source§impl From<Number> for Expression
impl From<Number> for Expression
Source§impl PartialOrd for Number
impl PartialOrd for Number
impl Copy for Number
impl Eq for Number
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