Enum entity::Number [−][src]
pub enum Number { }
Represents a generic number that maintains an internal Rust representation of the actual number
Variants
F32(f32)
F64(f64)
I128(i128)
I16(i16)
I32(i32)
I64(i64)
I8(i8)
Isize(isize)
U128(u128)
U16(u16)
U32(u32)
U64(u64)
U8(u8)
Usize(usize)
Implementations
impl Number
[src]
pub fn sign(&self) -> NumberSign
[src]
Returns an indicator of the sign (negative, zero, positive) of this number
use entity::{Number, NumberSign}; assert_eq!(Number::from(0).sign(), NumberSign::Zero); assert_eq!(Number::from(99).sign(), NumberSign::Positive); assert_eq!(Number::from(-99).sign(), NumberSign::Negative);
pub fn is_zero(&self) -> bool
[src]
Returns true if number is zero (not negative or positive)
use entity::Number; assert!(Number::from(0).is_zero()); assert!(!Number::from(1).is_zero()); assert!(!Number::from(-1).is_zero());
pub fn is_positive(&self) -> bool
[src]
Returns true if number is positive (not zero or negative)
Examples
use entity::Number; assert!(Number::from(1).is_positive()); assert!(!Number::from(0).is_positive()); assert!(!Number::from(-1).is_positive());
pub fn is_negative(&self) -> bool
[src]
Returns true if number is negative (not zero or positive)
Examples
use entity::Number; assert!(Number::from(-1).is_negative()); assert!(!Number::from(0).is_negative()); assert!(!Number::from(1).is_negative());
pub fn is_signed(&self) -> bool
[src]
Returns true if number is a signed integer
Examples
use entity::Number; assert!(Number::from(3isize).is_signed()); assert!(!Number::from(3usize).is_signed());
pub fn is_unsigned(&self) -> bool
[src]
Returns true if number is an unsigned integer
Examples
use entity::Number; assert!(Number::from(3usize).is_unsigned()); assert!(!Number::from(3isize).is_unsigned());
pub fn is_float(&self) -> bool
[src]
Returns true if number is a float
Examples
use entity::Number; assert!(Number::from(3f32).is_float()); assert!(!Number::from(3usize).is_float());
pub fn has_nonzero_fraction(&self) -> bool
[src]
Returns true if number is a float with a non-zero fractional part
Examples
use entity::Number; assert!(Number::from(3.1).has_nonzero_fraction()); assert!(!Number::from(3.0).has_nonzero_fraction());
pub fn is_normal(&self) -> bool
[src]
Returns true if number is neither zero, infinite, subnormal, or NaN
Examples
use entity::Number; assert!(Number::from(1).is_normal()); assert!(Number::from(0.1).is_normal()); assert!(!Number::from(0).is_normal()); assert!(!Number::from(f64::NAN).is_normal()); assert!(!Number::from(f64::INFINITY).is_normal()); assert!(!Number::from(f64::NEG_INFINITY).is_normal()); assert!(!Number::from(1.0e-308_f64).is_normal());
pub fn to_absolute(&self) -> Self
[src]
Returns a conversion of the underlying number to an absolute version of itself
pub fn to_f64(&self) -> f64
[src]
Naive casting of number’s inner representation to f64by performing x as f64
pub fn to_f32(&self) -> f32
[src]
Naive casting of number’s inner representation to f32by performing x as f32
pub fn to_isize(&self) -> isize
[src]
Naive casting of number’s inner representation to isizeby performing x as isize
pub fn to_i128(&self) -> i128
[src]
Naive casting of number’s inner representation to i128by performing x as i128
pub fn to_i64(&self) -> i64
[src]
Naive casting of number’s inner representation to i64by performing x as i64
pub fn to_i32(&self) -> i32
[src]
Naive casting of number’s inner representation to i32by performing x as i32
pub fn to_i16(&self) -> i16
[src]
Naive casting of number’s inner representation to i16by performing x as i16
pub fn to_i8(&self) -> i8
[src]
Naive casting of number’s inner representation to i8by performing x as i8
pub fn to_usize(&self) -> usize
[src]
Naive casting of number’s inner representation to usizeby performing x as usize
pub fn to_u128(&self) -> u128
[src]
Naive casting of number’s inner representation to u128by performing x as u128
pub fn to_u64(&self) -> u64
[src]
Naive casting of number’s inner representation to u64by performing x as u64
pub fn to_u32(&self) -> u32
[src]
Naive casting of number’s inner representation to u32by performing x as u32
pub fn to_u16(&self) -> u16
[src]
Naive casting of number’s inner representation to u16by performing x as u16
pub fn to_u8(&self) -> u8
[src]
Naive casting of number’s inner representation to u8by performing x as u8
pub fn to_type(&self) -> NumberType
[src]
Converts into type of number
Trait Implementations
impl Clone for Number
[src]
impl Copy for Number
[src]
impl Debug for Number
[src]
impl Eq for Number
[src]
impl<'_enum> From<&'_enum Number> for NumberType
[src]
fn from(val: &'_enum Number) -> NumberType
[src]
impl From<Number> for NumberType
[src]
fn from(val: Number) -> NumberType
[src]
impl From<f32> for Number
[src]
impl From<f64> for Number
[src]
impl From<i128> for Number
[src]
impl From<i16> for Number
[src]
impl From<i32> for Number
[src]
impl From<i64> for Number
[src]
impl From<i8> for Number
[src]
impl From<isize> for Number
[src]
impl From<u128> for Number
[src]
impl From<u16> for Number
[src]
impl From<u32> for Number
[src]
impl From<u64> for Number
[src]
impl From<u8> for Number
[src]
impl From<usize> for Number
[src]
impl Hash for Number
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl NumberLike for Number
[src]
fn into_number(self) -> Number
[src]
fn try_from_number(number: Number) -> Result<Self, Number>
[src]
impl PartialEq<Number> for Number
[src]
impl PartialOrd<Number> for Number
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
Compares two numbers if possible. If either number is not zero and not normal as defined by Rust’s specification, None is returned.
self sign | other sign | situation |
---|---|---|
negative | negative | does comparison (less/equal/greater) |
negative | positive | less than |
negative | zero | less than |
positive | negative | greater than |
positive | positive | does comparison (less/equal/greater) |
positive | zero | greater than |
zero | negative | greater than |
zero | positive | less than |
zero | zero | equal |
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for Number
impl Send for Number
impl Sync for Number
impl Unpin for Number
impl UnwindSafe for Number
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,