Struct Generics

Source
pub struct Generics {
    pub lt_token: Option<Lt>,
    pub params: Punctuated<GenericParam, Comma>,
    pub gt_token: Option<Gt>,
    pub where_clause: Option<WhereClause>,
}
Expand description

Lifetimes and type parameters attached an item

This is a custom variant of syn::Generics which supports trait as a parameter bound.

Fields§

§lt_token: Option<Lt>

<

§params: Punctuated<GenericParam, Comma>

Parameters

§gt_token: Option<Gt>

>

§where_clause: Option<WhereClause>

where bounds

Implementations§

Source§

impl Generics

Source

pub fn impl_generics( self, item_generics: &Generics, subst: &TokenStream, ) -> (TokenStream, TokenStream)

Generate (impl_generics, where_clause) tokens

Combines generics from self and item_generics.

This is the equivalent of the first and third items output by syn::Generics::split_for_impl. Any instance of trait as a parameter bound is replaced by subst.

Note: use ty_generics from syn::Generics::split_for_impl or Self::ty_generics as appropriate.

Source

pub fn ty_generics(&self, item_generics: &Generics) -> TokenStream

Generate ty_generics tokens

Combines generics from self and item_generics.

This is the equivalent to the second item output by syn::Generics::split_for_impl.

Trait Implementations§

Source§

impl Debug for Generics

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Generics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Parse for Generics

Source§

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

Source§

impl ToTokensSubst for Generics

Source§

fn to_tokens_subst(&self, tokens: &mut TokenStream, subst: &TokenStream)

Write self to the given TokenStream

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.