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 const fn value(&self) -> u64
pub const fn value(&self) -> u64
Returns the value of this literal.
Examples found in repository?
More examples
examples/calc.rs (line 86)
81fn primary(input: ParseStream) -> Result<Expr> {
82 let lookahead = input.lookahead();
83 if lookahead.peek(token::LitFloat) {
84 Ok(Expr::Num(input.parse::<token::LitFloat>()?.value()))
85 } else if lookahead.peek(token::LitInt) {
86 Ok(Expr::Num(input.parse::<token::LitInt>()?.value() as f64))
87 } else if lookahead.peek(token::LeftParen) {
88 let group: Group<Parentheses> = input.parse()?;
89 parse(group.into_token_stream())
90 } else {
91 Err(lookahead.error())
92 }
93}
Sourcepub fn parse_decimal(input: ParseStream<'_>) -> Result<Self>
pub fn parse_decimal(input: ParseStream<'_>) -> Result<Self>
Trait Implementations§
Source§impl Ord for LitInt
impl Ord for LitInt
Source§impl PartialOrd for LitInt
impl PartialOrd for LitInt
Source§impl ToTokens for LitInt
impl ToTokens for LitInt
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Append
self
to the given TokenStream
.Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Convert
self
directly into a TokenStream
.Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Convert
self
directly into a TokenStream
.Source§impl ToTokens for LitInt
Available on crate feature proc-macro2
only.
impl ToTokens for LitInt
Available on crate feature
proc-macro2
only.Source§fn to_tokens(&self, tokens: &mut TokenStream2)
fn to_tokens(&self, tokens: &mut TokenStream2)
Source§fn to_token_stream(&self) -> TokenStream2
fn to_token_stream(&self) -> TokenStream2
Source§fn into_token_stream(self) -> TokenStream2
fn into_token_stream(self) -> TokenStream2
impl Eq for LitInt
Auto Trait Implementations§
impl Freeze for LitInt
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