Skip to main content

Number

Struct Number 

Source
pub struct Number { /* private fields */ }
Expand description

A YAML integer or floating-point number.

Unlike yaml_serde::Number, this type retains the full Serde i128 and u128 ranges.

Implementations§

Source§

impl Number

Source

pub fn is_i64(&self) -> bool

Returns true when this is an integer representable as i64.

Source

pub fn is_u64(&self) -> bool

Returns true when this is an integer representable as u64.

Source

pub const fn is_f64(&self) -> bool

Returns true when this was represented as a floating-point number.

Source

pub fn is_i128(&self) -> bool

Returns true when this is an integer representable as i128.

Source

pub fn is_u128(&self) -> bool

Returns true when this is an integer representable as u128.

Source

pub fn as_i64(&self) -> Option<i64>

Returns the integer as i64 when it fits.

Source

pub fn as_u64(&self) -> Option<u64>

Returns the integer as u64 when it fits.

Source

pub fn as_i128(&self) -> Option<i128>

Returns the integer as i128 when it fits.

Source

pub fn as_u128(&self) -> Option<u128>

Returns the integer as u128 when it is non-negative.

Source

pub fn as_f64(&self) -> Option<f64>

Returns this number as f64.

Source

pub fn is_nan(&self) -> bool

Returns true when this is NaN.

Source

pub fn is_infinite(&self) -> bool

Returns true when this is positive or negative infinity.

Source

pub fn is_finite(&self) -> bool

Returns true when this is not infinity or NaN.

Trait Implementations§

Source§

impl Clone for Number

Source§

fn clone(&self) -> Number

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Number

Source§

impl Debug for Number

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Number

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Number, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Number

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<f32> for Number

Source§

fn from(value: f32) -> Number

Converts to this type from the input type.
Source§

impl From<f64> for Number

Source§

fn from(value: f64) -> Number

Converts to this type from the input type.
Source§

impl From<i8> for Number

Source§

fn from(value: i8) -> Number

Converts to this type from the input type.
Source§

impl From<i16> for Number

Source§

fn from(value: i16) -> Number

Converts to this type from the input type.
Source§

impl From<i32> for Number

Source§

fn from(value: i32) -> Number

Converts to this type from the input type.
Source§

impl From<i64> for Number

Source§

fn from(value: i64) -> Number

Converts to this type from the input type.
Source§

impl From<i128> for Number

Source§

fn from(value: i128) -> Number

Converts to this type from the input type.
Source§

impl From<isize> for Number

Source§

fn from(value: isize) -> Number

Converts to this type from the input type.
Source§

impl From<u8> for Number

Source§

fn from(value: u8) -> Number

Converts to this type from the input type.
Source§

impl From<u16> for Number

Source§

fn from(value: u16) -> Number

Converts to this type from the input type.
Source§

impl From<u32> for Number

Source§

fn from(value: u32) -> Number

Converts to this type from the input type.
Source§

impl From<u64> for Number

Source§

fn from(value: u64) -> Number

Converts to this type from the input type.
Source§

impl From<u128> for Number

Source§

fn from(value: u128) -> Number

Converts to this type from the input type.
Source§

impl From<usize> for Number

Source§

fn from(value: usize) -> Number

Converts to this type from the input type.
Source§

impl FromStr for Number

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<Number, Error>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Number

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'de> IntoDeserializer<'de, Error> for Number

Source§

type Deserializer = Value

The type of the deserializer being converted into.
Source§

fn into_deserializer( self, ) -> <Number as IntoDeserializer<'de, Error>>::Deserializer

Convert this value into a deserializer.
Source§

impl PartialEq for Number

Source§

fn eq(&self, other: &Number) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Number

Source§

fn partial_cmp(&self, other: &Number) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Number

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.