Enum Type

#[non_exhaustive]
pub enum Type

The possible types that a Rust value could have.

Syntax tree enum

This type is a syntax tree enum.

Variants

Array(TypeArray)

A fixed size array type: [T; n].

FnPtr(TypeFnPtr)

A function pointer type: fn(usize) -> bool.

Group(TypeGroup)

A type contained within invisible delimiters.

ImplTrait(TypeImplTrait)

An impl Bound1 + Bound2 + Bound3 type where Bound is a trait or a lifetime.

Infer(TypeInfer)

Indication that a type should be inferred by the compiler: _.

Macro(TypeMacro)

A macro in the type position.

Never(TypeNever)

The never type: !.

Paren(TypeParen)

A parenthesized type equivalent to the inner type.

Path(TypePath)

A path like core::slice::Iter, optionally qualified with a self-type as in <Vec<T> as SomeTrait>::Associated.

Ptr(TypePtr)

A raw pointer type: *const T or *mut T.

Reference(TypeReference)

A reference type: &'a T or &'a mut T.

Slice(TypeSlice)

A dynamically sized slice type: [T].

TraitObject(TypeTraitObject)

A trait object type dyn Bound1 + Bound2 + Bound3 where Bound is a trait or a lifetime.

Tuple(TypeTuple)

A tuple type: (A, B, C, String).

Verbatim(TokenStream)

Tokens in type position not interpreted by Syn.

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

Implementations

impl Type

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

In some positions, types may not contain the + character, to disambiguate them. For example in the expression 1 as T, T may not contain a + character.

This parser does not allow a +, while the default parser does.

Trait Implementations

impl Clone for Type

fn clone(&self) -> Self

impl Parse for Type

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

impl ToTokens for Type

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

Auto Trait Implementations

impl !Send for Type

impl !Sync for Type

impl Freeze for Type

impl RefUnwindSafe for Type

impl Unpin for Type

impl UnsafeUnpin for Type

impl UnwindSafe for Type

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for Type

fn from(t: T) -> T

Returns the argument unchanged.

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

fn span(&self) -> Span

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

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

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

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

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

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