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

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

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.

Returns the non-empty integer part of this literal.

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..

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

The optional type suffix.

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

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

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

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

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.