Struct Nothing

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)]
  |           ^^^^

Implementations

impl Clone for Nothing

fn clone(self: &Self) -> Self

impl Copy for Nothing

impl Debug for Nothing

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

impl Eq for Nothing

impl Freeze for Nothing

impl Hash for Nothing

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

impl Parse for Nothing

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

impl PartialEq for Nothing

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

impl RefUnwindSafe for Nothing

impl Send for Nothing

impl Sync for Nothing

impl ToTokens for Nothing

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

impl Unpin for Nothing

impl UnwindSafe for Nothing

impl<T> Any for Nothing

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Nothing

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

impl<T> BorrowMut for Nothing

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

impl<T> CloneToUninit for Nothing

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

impl<T> From for Nothing

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Spanned for Nothing

fn span(self: &Self) -> Span

impl<T> ToOwned for Nothing

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

impl<T, U> Into for Nothing

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 Nothing

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

impl<T, U> TryInto for Nothing

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