pub trait Number: Eq {
// Required methods
fn as_u32(&self) -> Option<u32>;
fn as_u64(&self) -> Option<u64>;
fn as_i32(&self) -> Option<i32>;
fn as_i64(&self) -> Option<i64>;
fn as_f32(&self) -> Option<f32>;
fn as_f32_lossy(&self) -> f32;
fn as_f64(&self) -> Option<f64>;
fn as_f64_lossy(&self) -> f64;
}Expand description
JSON number.
Required Methods§
Sourcefn as_u32(&self) -> Option<u32>
fn as_u32(&self) -> Option<u32>
Returns this number as an u32 if it can be exactly represented as such.
Sourcefn as_u64(&self) -> Option<u64>
fn as_u64(&self) -> Option<u64>
Returns this number as an u64 if it can be exactly represented as such.
Sourcefn as_i32(&self) -> Option<i32>
fn as_i32(&self) -> Option<i32>
Returns this number as an i32 if it can be exactly represented as such.
Sourcefn as_i64(&self) -> Option<i64>
fn as_i64(&self) -> Option<i64>
Returns this number as an i64 if it can be exactly represented as such.
Sourcefn as_f32(&self) -> Option<f32>
fn as_f32(&self) -> Option<f32>
Returns this number as an f32 if it can be exactly represented as such.
Sourcefn as_f32_lossy(&self) -> f32
fn as_f32_lossy(&self) -> f32
Returns this number as an f32, potentially losing precision in the process.
Sourcefn as_f64(&self) -> Option<f64>
fn as_f64(&self) -> Option<f64>
Returns this number as an f64 if it can be exactly represented as such.
Sourcefn as_f64_lossy(&self) -> f64
fn as_f64_lossy(&self) -> f64
Returns this number as an f64, potentially losing precision in the process.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.