# Enum syn::Type [−] [src]

    pub enum Type {
        Array(TypeArray),
        BareFn(TypeBareFn),
        Group(TypeGroup),
        ImplTrait(TypeImplTrait),
        Infer(TypeInfer),
        Macro(TypeMacro),
        Never(TypeNever),
        Paren(TypeParen),
        Path(TypePath),
        Ptr(TypePtr),
        Reference(TypeReference),
        Slice(TypeSlice),
        TraitObject(TypeTraitObject),
        Tuple(TypeTuple),
        Verbatim(TokenStream),
        // some variants omitted
    }

The possible types that a Rust value could have.

This type is available only if Syn is built with the `"derive"` or `"full"` feature.

# Syntax tree enum

This type is a syntax tree enum.

## Variants

`Array(TypeArray)`

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

`BareFn(TypeBareFn)`

A bare function 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 `std::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 `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.

## Implementations

### `impl Type` [src]

#### `pub fn without_plus(input: ParseStream<'_>) -> Result<Self>` [src]

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` [src]

#### `fn clone(&self) -> Self` [src]

Returns a copy of the value. Read more

#### `pub fn clone_from(&mut self, source: &Self)`1.0.0 [src]

Performs copy-assignment from `source`. Read more

### `impl From<TypeArray> for Type` [src]

#### `fn from(e: TypeArray) -> Type` [src]

Performs the conversion.

### `impl From<TypeBareFn> for Type` [src]

#### `fn from(e: TypeBareFn) -> Type` [src]

Performs the conversion.

### `impl From<TypeGroup> for Type` [src]

#### `fn from(e: TypeGroup) -> Type` [src]

Performs the conversion.

### `impl From<TypeImplTrait> for Type` [src]

#### `fn from(e: TypeImplTrait) -> Type` [src]

Performs the conversion.

### `impl From<TypeInfer> for Type` [src]

#### `fn from(e: TypeInfer) -> Type` [src]

Performs the conversion.

### `impl From<TypeMacro> for Type` [src]

#### `fn from(e: TypeMacro) -> Type` [src]

Performs the conversion.

### `impl From<TypeNever> for Type` [src]

#### `fn from(e: TypeNever) -> Type` [src]

Performs the conversion.

### `impl From<TypeParen> for Type` [src]

#### `fn from(e: TypeParen) -> Type` [src]

Performs the conversion.

### `impl From<TypePath> for Type` [src]

#### `fn from(e: TypePath) -> Type` [src]

Performs the conversion.

### `impl From<TypePtr> for Type` [src]

#### `fn from(e: TypePtr) -> Type` [src]

Performs the conversion.

### `impl From<TypeReference> for Type` [src]

#### `fn from(e: TypeReference) -> Type` [src]

Performs the conversion.

### `impl From<TypeSlice> for Type` [src]

#### `fn from(e: TypeSlice) -> Type` [src]

Performs the conversion.

### `impl From<TypeTraitObject> for Type` [src]

#### `fn from(e: TypeTraitObject) -> Type` [src]

Performs the conversion.

### `impl From<TypeTuple> for Type` [src]

#### `fn from(e: TypeTuple) -> Type` [src]

Performs the conversion.

### `impl Parse for Type` [src]

#### `fn parse(input: ParseStream<'_>) -> Result<Self>` [src]

### `impl ToTokens for Type` [src]

#### `fn to_tokens(&self, tokens: &mut TokenStream)` [src]

Write `self` to the given `TokenStream`. Read more

#### `pub fn to_token_stream(&self) -> TokenStream` [src]

Convert `self` directly into a `TokenStream` object. Read more

#### `pub fn into_token_stream(self) -> TokenStream` [src]

Convert `self` directly into a `TokenStream` object. Read more

## Auto Trait Implementations

### `impl RefUnwindSafe for Type`

### `impl !Send for Type`

### `impl !Sync for Type`

### `impl Unpin for Type`

### `impl UnwindSafe for Type`

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T> Spanned for T where
T: Spanned + ?Sized,` [src]

#### `pub fn span(&Self) -> Span` [src]

Returns a `Span` covering the complete contents of this syntax tree node, or `Span::call_site()` if this node is empty. Read more

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `pub fn to_owned(&self) -> T` [src]

Creates owned data from borrowed data, usually by cloning. Read more

#### `pub fn clone_into(&self, target: &mut T)` [src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.