pub trait AttachGenerics<'a> {
    type Output;

    // Required method
    fn with_optional_generics<G>(
        self,
        generics: Option<G>
    ) -> WithGenerics<'a, Self::Output>
       where G: Into<MaybeBorrowed<'a, Generics>>;

    // Provided method
    fn with_generics<G>(self, generics: G) -> WithGenerics<'a, Self::Output>
       where G: Into<MaybeBorrowed<'a, Generics>>,
             Self: Sized { ... }
}
Expand description

A trait meant to be implemented for all types that may want some generics to be attached to them.

Required Associated Types§

source

type Output

An optional type wrapper around the type the generics will be attached to Used by this crate to wrap types with MaybeBorrowed to allow both references and owned types to be represented by the same type.

Required Methods§

source

fn with_optional_generics<G>( self, generics: Option<G> ) -> WithGenerics<'a, Self::Output>where G: Into<MaybeBorrowed<'a, Generics>>,

Provided Methods§

source

fn with_generics<G>(self, generics: G) -> WithGenerics<'a, Self::Output>where G: Into<MaybeBorrowed<'a, Generics>>, Self: Sized,

Attach some generics G to Self. This allows for the generics to to not exactly be syn::Generics but any type that can be turned into MaybeBorrowed<syn::Generics>. This allows for both &syn::Generics and syn::Generics to be attached using the same trait.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, Gen> AttachGenerics<'a> for MaybeBorrowed<'a, Gen>where Gen: Generatable<'a>,

§

type Output = MaybeBorrowed<'a, Gen>

source§

impl<'a, Gen> AttachGenerics<'a> for Assert<'a, Gen>where Gen: Generatable<'a>,

§

type Output = Assert<'a, Gen>

source§

impl<'a, Gen> AttachGenerics<'a> for Genwhere Gen: Generatable<'a>,

§

type Output = MaybeBorrowed<'a, Gen>