Struct litrs::FloatLit[][src]

pub struct FloatLit<B: Buffer> { /* fields omitted */ }
Expand description

A floating point literal, e.g. 3.14, 8., 135e12, 27f32 or 1.956e2f64.

This kind of literal has several forms, but generally consists of a main number part, an optional exponent and an optional type suffix. See the reference for more information.

A leading minus sign - is not part of the literal grammar! -3.14 are two tokens in the Rust grammar.

Implementations

impl<B: Buffer> FloatLit<B>[src]

pub fn parse(s: B) -> Result<Self, Error>[src]

Parses the input as a floating point literal. Returns an error if the input is invalid or represents a different kind of literal.

pub fn number_part(&self) -> &str[src]

Returns the whole number part (including integer part, fractional part and exponent), but without the type suffix. If you want an actual floating point value, you need to parse this string, e.g. with f32::from_str or an external crate.

pub fn integer_part(&self) -> &str[src]

Returns the non-empty integer part of this literal.

pub fn fractional_part(&self) -> Option<&str>[src]

Returns the optional fractional part of this literal. Does not include the period. If a period exists in the input, Some is returned, None otherwise. Note that Some("") might be returned, e.g. for 3..

pub fn exponent_part(&self) -> &str[src]

Optional exponent part. Might be empty if there was no exponent part in the input. Includes the e or E at the beginning.

pub fn type_suffix(&self) -> Option<FloatType>[src]

The optional type suffix.

impl FloatLit<&str>[src]

pub fn to_owned(&self) -> FloatLit<String>[src]

Makes a copy of the underlying buffer and returns the owned version of Self.

Trait Implementations

impl<B: Clone + Buffer> Clone for FloatLit<B>[src]

fn clone(&self) -> FloatLit<B>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<B: Debug + Buffer> Debug for FloatLit<B>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<B: Buffer> Display for FloatLit<B>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<B: PartialEq + Buffer> PartialEq<FloatLit<B>> for FloatLit<B>[src]

fn eq(&self, other: &FloatLit<B>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &FloatLit<B>) -> bool[src]

This method tests for !=.

impl<B: Copy + Buffer> Copy for FloatLit<B>[src]

impl<B: Eq + Buffer> Eq for FloatLit<B>[src]

impl<B: Buffer> StructuralEq for FloatLit<B>[src]

impl<B: Buffer> StructuralPartialEq for FloatLit<B>[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for FloatLit<B> where
    B: RefUnwindSafe

impl<B> Send for FloatLit<B> where
    B: Send

impl<B> Sync for FloatLit<B> where
    B: Sync

impl<B> Unpin for FloatLit<B> where
    B: Unpin

impl<B> UnwindSafe for FloatLit<B> where
    B: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.