Struct LitInt

struct LitInt { ... }

An integer literal: 1 or 1u16.

Implementations

impl LitInt

fn new(repr: &str, span: Span) -> Self
fn base10_digits(self: &Self) -> &str
fn base10_parse<N>(self: &Self) -> Result<N>
where
    N: FromStr,
    <N as >::Err: Display

Parses the literal into a selected number type.

This is equivalent to lit.base10_digits().parse() except that the resulting errors will be correctly spanned to point to the literal token in the macro input.

use syn::LitInt;
use syn::parse::{Parse, ParseStream, Result};

struct Port {
    value: u16,
}

impl Parse for Port {
    fn parse(input: ParseStream) -> Result<Self> {
        let lit: LitInt = input.parse()?;
        let value = lit.base10_parse::<u16>()?;
        Ok(Port { value })
    }
}
fn suffix(self: &Self) -> &str
fn span(self: &Self) -> Span
fn set_span(self: &mut Self, span: Span)
fn token(self: &Self) -> Literal

impl Clone for LitInt

fn clone(self: &Self) -> Self

impl Debug for LitInt

fn fmt(self: &Self, formatter: &mut Formatter<'_>) -> Result

impl Display for LitInt

fn fmt(self: &Self, formatter: &mut Formatter<'_>) -> Result

impl Eq for LitInt

impl Freeze for LitInt

impl From for LitInt

fn from(token: Literal) -> Self

impl Hash for LitInt

fn hash<H>(self: &Self, state: &mut H)
where
    H: Hasher

impl Parse for LitInt

fn parse(input: ParseStream<'_>) -> Result<Self>

impl PartialEq for LitInt

fn eq(self: &Self, other: &Self) -> bool

impl RefUnwindSafe for LitInt

impl Send for LitInt

impl Sync for LitInt

impl ToTokens for LitInt

fn to_tokens(self: &Self, tokens: &mut TokenStream)

impl Token for LitInt

impl Unpin for LitInt

impl UnsafeUnpin for LitInt

impl UnwindSafe for LitInt

impl<T> Any for LitInt

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for LitInt

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for LitInt

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for LitInt

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for LitInt

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Spanned for LitInt

fn span(self: &Self) -> Span

impl<T> ToOwned for LitInt

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for LitInt

fn to_string(self: &Self) -> String

impl<T, U> Into for LitInt

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for LitInt

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for LitInt

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>