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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)