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.
Trait Implementations
Auto Trait Implementations
impl<B> RefUnwindSafe for FloatLit<B> where
B: RefUnwindSafe,
impl<B> UnwindSafe for FloatLit<B> where
B: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more