Enum Item

#[non_exhaustive]
pub enum Item

Things that can appear directly inside of a module or scope.

Syntax tree enum

This type is a syntax tree enum.

Variants

Const(ItemConst)

A constant item: const MAX: u16 = 65535.

Enum(ItemEnum)

An enum definition: enum Foo<A, B> { A(A), B(B) }.

ExternCrate(ItemExternCrate)

An extern crate item: extern crate serde.

Fn(ItemFn)

A free-standing function: fn process(n: usize) -> Result<()> { ... }.

ForeignMod(ItemForeignMod)

A block of foreign items: extern "C" { ... }.

Impl(ItemImpl)

An impl block providing trait or associated items: impl<A> Trait for Data<A> { ... }.

Macro(ItemMacro)

A macro invocation, which includes macro_rules! definitions.

Mod(ItemMod)

A module or module declaration: mod m or mod m { ... }.

Static(ItemStatic)

A static item: static BIKE: Shed = Shed(42).

Struct(ItemStruct)

A struct definition: struct Foo<A> { x: A }.

Trait(ItemTrait)

A trait definition: pub trait Iterator { ... }.

TraitAlias(ItemTraitAlias)

A trait alias: pub trait SharableIterator = Iterator + Sync.

Type(ItemType)

A type alias: type Result<T> = core::result::Result<T, MyError>.

Union(ItemUnion)

A union definition: union Foo<A, B> { x: A, y: B }.

Use(ItemUse)

A use declaration: use alloc::collections::HashMap.

Verbatim(TokenStream)

Tokens forming an item not interpreted by Syn.

Important: see [Compatibility notes][crate#verbatim-variants].

Trait Implementations

impl Clone for Item

fn clone(&self) -> Self

impl From<DeriveInput> for Item

fn from(input: DeriveInput) -> Item

impl Parse for Item

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

impl ToTokens for Item

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

Auto Trait Implementations

impl !Send for Item

impl !Sync for Item

impl Freeze for Item

impl RefUnwindSafe for Item

impl Unpin for Item

impl UnsafeUnpin for Item

impl UnwindSafe for Item

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for Item

fn from(t: T) -> T

Returns the argument unchanged.

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

fn span(&self) -> Span

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

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

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

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

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

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