pub enum Number {
Integer(i64),
Float(Float),
}
Variants§
Implementations§
source§impl Number
impl Number
sourcepub fn map_to<T>(
self,
integer_fn: impl FnOnce(i64) -> T,
float_fn: impl FnOnce(f64) -> T,
) -> T
pub fn map_to<T>( self, integer_fn: impl FnOnce(i64) -> T, float_fn: impl FnOnce(f64) -> T, ) -> T
Map this number to a single type using the appropriate closure.
§Example
let i = Number::new(5);
let f = Number::new(2.0);
assert!(i.map_to(|i| i > 3, |f| f > 3.0));
assert!(!f.map_to(|i| i > 3, |f| f > 3.0));
Trait Implementations§
source§impl From<u64> for Number
impl From<u64> for Number
The following Number
conversion checks if the integer fits losslessly
into an i64
, before constructing a Number::Integer
variant.
If not, the conversion defaults to Number::Float
.
source§impl Ord for Number
impl Ord for Number
source§impl PartialEq for Number
impl PartialEq for Number
source§impl PartialOrd for Number
impl PartialOrd for Number
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl 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