Struct Nothing

pub struct Nothing;

An empty syntax tree node that consumes no tokens when parsed.

This is useful for attribute macros that want to ensure they are not provided any attribute args.

# extern crate proc_macro;
#
use proc_macro::TokenStream;
use syn::parse_macro_input;
use syn::parse::Nothing;

# const IGNORE: &str = stringify! {
#[proc_macro_attribute]
# };
pub fn my_attr(args: TokenStream, input: TokenStream) -> TokenStream {
    parse_macro_input!(args as Nothing);

    /* ... */
#   TokenStream::new()
}
error: unexpected token
 --> src/main.rs:3:19
  |
3 | #[my_attr(asdf)]
  |           ^^^^

Trait Implementations

impl Clone for Nothing

fn clone(&self) -> Self

impl Copy for Nothing

impl Parse for Nothing

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

impl ToTokens for Nothing

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

Auto Trait Implementations

impl Freeze for Nothing

impl RefUnwindSafe for Nothing

impl Send for Nothing

impl Sync for Nothing

impl Unpin for Nothing

impl UnsafeUnpin for Nothing

impl UnwindSafe for Nothing

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for Nothing

fn from(t: T) -> T

Returns the argument unchanged.

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

fn span(&self) -> Span

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

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

impl<T, U> Into<U> for Nothing 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 Nothing where U: Into<T>,

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

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

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