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]
impl<B: Buffer> FloatLit<B>
[src]pub fn parse(s: B) -> Result<Self, Error>
[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]
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]
pub fn integer_part(&self) -> &str
[src]Returns the non-empty integer part of this literal.
pub fn fractional_part(&self) -> Option<&str>
[src]
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]
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]
pub fn type_suffix(&self) -> Option<FloatType>
[src]The optional type suffix.
Trait Implementations
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,
B: RefUnwindSafe,
impl<B> Send for FloatLit<B> where
B: Send,
B: Send,
impl<B> Sync for FloatLit<B> where
B: Sync,
B: Sync,
impl<B> Unpin for FloatLit<B> where
B: Unpin,
B: Unpin,
impl<B> UnwindSafe for FloatLit<B> where
B: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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