Struct flexi_parse::token::LitFloat
source · pub struct LitFloat { /* private fields */ }Expand description
A string of ascii digits followed by a ., and then another string of
ascii digits.
Implementations§
source§impl LitFloat
impl LitFloat
sourcepub fn value(&self) -> f64
pub fn value(&self) -> f64
Returns the value of this literal.
Examples found in repository?
More examples
examples/calc.rs (line 85)
82 83 84 85 86 87 88 89 90 91 92 93 94
fn primary(input: ParseStream<'_>) -> Result<Expr> {
let lookahead = input.lookahead();
if lookahead.peek(token::LitFloat) {
Ok(Expr::Num(input.parse::<token::LitFloat>()?.value()))
} else if lookahead.peek(token::LitInt) {
Ok(Expr::Num(input.parse::<token::LitInt>()?.value() as f64))
} else if lookahead.peek(token::LeftParen) {
let group: Group<Parentheses> = input.parse()?;
parse(group.into_token_stream())
} else {
Err(lookahead.error())
}
}Trait Implementations§
source§impl Parse for LitFloat
impl Parse for LitFloat
source§fn parse(input: ParseStream<'_>) -> Result<Self>
fn parse(input: ParseStream<'_>) -> Result<Self>
Parses the input into this type.
source§impl PartialEq<LitFloat> for LitFloat
impl PartialEq<LitFloat> for LitFloat
source§impl PartialOrd<LitFloat> for LitFloat
impl PartialOrd<LitFloat> for LitFloat
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreAuto Trait Implementations§
impl RefUnwindSafe for LitFloat
impl !Send for LitFloat
impl !Sync for LitFloat
impl Unpin for LitFloat
impl UnwindSafe for LitFloat
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more