Trait AttachGenericsWithAssert

Source
pub trait AttachGenericsWithAssert<'a, A> {
    type Output;

    // Required method
    fn with_optional_generics<B>(
        self,
        generics: Option<impl Into<MaybeBorrowed<'a, Generics>>>,
    ) -> WithGenerics<'a, Self::Output>
       where B: TypeEq<This = A>;

    // Provided method
    fn with_generics<B>(
        self,
        generics: impl Into<MaybeBorrowed<'a, Generics>>,
    ) -> WithGenerics<'a, Self::Output>
       where B: TypeEq<This = A>,
             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<B>( self, generics: Option<impl Into<MaybeBorrowed<'a, Generics>>>, ) -> WithGenerics<'a, Self::Output>
where B: TypeEq<This = A>,

Provided Methods§

Source

fn with_generics<B>( self, generics: impl Into<MaybeBorrowed<'a, Generics>>, ) -> WithGenerics<'a, Self::Output>
where B: TypeEq<This = A>, 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, Gen, A> AttachGenericsWithAssert<'a, A> for Gen
where Gen: Generatable<'a, A>, A: 'a + TidAble<'a>,