Struct flexi_parse::token::LitInt
source · pub struct LitInt { /* private fields */ }Expand description
An integer literal.
The default parsing implementation accepts either a string of ascii digits,
or 0b, 0o, or 0x, followed by a number in base 2, 8, or 16
respectively.
Implementations§
source§impl LitInt
impl LitInt
sourcepub fn value(&self) -> u64
pub fn value(&self) -> u64
Returns the value of this literal.
Examples found in repository?
More examples
examples/calc.rs (line 87)
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())
}
}sourcepub fn parse_decimal(input: ParseStream<'_>) -> Result<Self>
pub fn parse_decimal(input: ParseStream<'_>) -> Result<Self>
Accepts a string of ascii digits.
Trait Implementations§
source§impl Ord for LitInt
impl Ord for LitInt
source§impl Parse for LitInt
impl Parse for LitInt
source§fn parse(input: ParseStream<'_>) -> Result<Self>
fn parse(input: ParseStream<'_>) -> Result<Self>
Parses the input into this type.
source§impl PartialEq<LitInt> for LitInt
impl PartialEq<LitInt> for LitInt
source§impl PartialOrd<LitInt> for LitInt
impl PartialOrd<LitInt> for LitInt
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 moreimpl Eq for LitInt
Auto Trait Implementations§
impl RefUnwindSafe for LitInt
impl !Send for LitInt
impl !Sync for LitInt
impl Unpin for LitInt
impl UnwindSafe for LitInt
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