Struct LitInt

pub struct LitInt { /* private fields */ }

An integer literal: 1 or 1u16.

Implementations

impl LitInt

fn new(repr: &str, span: Span) -> Self
fn base10_digits(&self) -> &str
fn base10_parse<N>(&self) -> Result<N>
where
    N: FromStr,
    N::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) -> &str
fn span(&self) -> Span
fn set_span(&mut self, span: Span)
fn token(&self) -> Literal

Trait Implementations

impl Clone for LitInt

fn clone(&self) -> Self

impl Display for LitInt

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

impl Parse for LitInt

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

impl ToTokens for LitInt

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

impl Token for LitInt

Auto Trait Implementations

impl !Send for LitInt

impl !Sync for LitInt

impl Freeze for LitInt

impl RefUnwindSafe for LitInt

impl Unpin for LitInt

impl UnsafeUnpin for LitInt

impl UnwindSafe for LitInt

Blanket Implementations

impl<T> Any for LitInt where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for LitInt where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for LitInt where T: ?Sized,

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

impl<T> CloneToUninit for LitInt where T: Clone,

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

impl<T> From<T> for LitInt

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Spanned for LitInt where T: Spanned + ?Sized,

fn span(&self) -> Span

impl<T> ToOwned for LitInt where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for LitInt where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for LitInt where U: From<T>,

fn into(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<U> for LitInt where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for LitInt where U: TryFrom<T>,

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