Struct proc_macro_assertions::generatable::Trait
source · pub struct Trait<'a> { /* private fields */ }
Expand description
A trait Generatable / Template. This asserts that some type implements some trait.
Implementations§
source§impl<'a> Trait<'a>
impl<'a> Trait<'a>
sourcepub fn new<T>(trait_bound: T) -> Selfwhere
T: Into<MaybeBorrowed<'a, TraitBound>>,
pub fn new<T>(trait_bound: T) -> Selfwhere T: Into<MaybeBorrowed<'a, TraitBound>>,
Creates a new trait template from some trait bound. Takes any T that can be turned into a MaybeBorrowed type, to support references as well as owned types
Trait Implementations§
source§impl<'a> FromMaybeBorrowed<'a, TraitBound> for Trait<'a>
impl<'a> FromMaybeBorrowed<'a, TraitBound> for Trait<'a>
fn from_maybe_borrowed(from: MaybeBorrowed<'a, TraitBound>) -> Self
fn from_owned(from: T) -> Selfwhere Self: Sized,
fn from_borrowed(from: &'a T) -> Selfwhere Self: Sized,
source§impl<'a> Generatable<'a> for Trait<'a>
impl<'a> Generatable<'a> for Trait<'a>
§type GeneratableData = ()
type GeneratableData = ()
The type of any data passed from the
Generatable
stage to proceeding stages.§type TemplateData = Ident
type TemplateData = Ident
The type of any data passed from the
Template
stage to proceeding stages.source§fn template(
&self,
_: &mut Context<'_>,
_passed: &Self::GeneratableData
) -> PassedData<Self::TemplateData>
fn template( &self, _: &mut Context<'_>, _passed: &Self::GeneratableData ) -> PassedData<Self::TemplateData>
This is the method the
Template
stage is composed of. Should return Tokens (if any) generated by this stage,
plus optionally any data passed to preceding stages.source§fn assert(
&self,
_context: &mut Context<'_>,
(_, assert_trait_bound): (&Self::GeneratableData, &Self::TemplateData),
to_assert: &Self::Assert
) -> Option<TokenStream>
fn assert( &self, _context: &mut Context<'_>, (_, assert_trait_bound): (&Self::GeneratableData, &Self::TemplateData), to_assert: &Self::Assert ) -> Option<TokenStream>
This is the method the
Assert
stage is composed of. Should return Tokens generated by this stage.source§fn generatable(_context: &mut Context<'_>) -> PassedData<Self::GeneratableData>where
Self: Sized,
fn generatable(_context: &mut Context<'_>) -> PassedData<Self::GeneratableData>where Self: Sized,
This is the method the
Generatable
stage is composed of. Should return Tokens (if any) generated by this stage,
plus optionally any data passed to preceding stages.source§impl<'a> Ord for Trait<'a>
impl<'a> Ord for Trait<'a>
source§impl<'a> PartialEq for Trait<'a>
impl<'a> PartialEq for Trait<'a>
source§impl<'a> PartialOrd for Trait<'a>
impl<'a> PartialOrd for Trait<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<'a> Eq for Trait<'a>
impl<'a> TidAble<'a> for Trait<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Trait<'a>
impl<'a> !Send for Trait<'a>
impl<'a> !Sync for Trait<'a>
impl<'a> Unpin for Trait<'a>
impl<'a> UnwindSafe for Trait<'a>
Blanket Implementations§
source§impl<T> AnyExt for Twhere
T: Any + ?Sized,
impl<T> AnyExt for Twhere T: Any + ?Sized,
source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where T: Any,
Attempts to downcast this to
T
behind referencesource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where T: Any,
Attempts to downcast this to
T
behind mutable referencesource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where T: Any,
Attempts to downcast this to
T
behind Rc
pointersource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where T: Any,
Attempts to downcast this to
T
behind Arc
pointersource§impl<'a, Gen> AttachGenerics<'a> for Genwhere
Gen: Generatable<'a>,
impl<'a, Gen> AttachGenerics<'a> for Genwhere Gen: Generatable<'a>,
§type Output = MaybeBorrowed<'a, Gen>
type Output = MaybeBorrowed<'a, Gen>
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.fn with_optional_generics<G>( self, generics: Option<G> ) -> WithGenerics<'a, <Gen as AttachGenerics<'a>>::Output>where G: Into<MaybeBorrowed<'a, Generics>>,
source§fn with_generics<G>(self, generics: G) -> WithGenerics<'a, Self::Output>where
G: Into<MaybeBorrowed<'a, Generics>>,
Self: Sized,
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.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<'a, T, U> ResolveBounds<'a, T> for Uwhere
T: AssertableWithBounds<'a, U> + 'a,
impl<'a, T, U> ResolveBounds<'a, T> for Uwhere T: AssertableWithBounds<'a, U> + 'a,
fn resolve_for( self, assertable: impl Into<MaybeBorrowed<'a, T>> ) -> ResolvedBounds<'a, U, T>
source§impl<'a, X> TidExt<'a> for Xwhere
X: Tid<'a> + ?Sized,
impl<'a, X> TidExt<'a> for Xwhere X: Tid<'a> + ?Sized,
source§fn is<T>(&self) -> boolwhere
T: Tid<'a>,
fn is<T>(&self) -> boolwhere T: Tid<'a>,
Returns true if type behind self is equal to the type of T.
source§fn downcast_ref<T, 'b>(&'b self) -> Option<&'b T>where
T: Tid<'a>,
fn downcast_ref<T, 'b>(&'b self) -> Option<&'b T>where T: Tid<'a>,
Attempts to downcast self to
T
behind referencesource§fn downcast_mut<T, 'b>(&'b mut self) -> Option<&'b mut T>where
T: Tid<'a>,
fn downcast_mut<T, 'b>(&'b mut self) -> Option<&'b mut T>where T: Tid<'a>,
Attempts to downcast self to
T
behind mutable referencesource§fn downcast_rc<T>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Tid<'a>,
fn downcast_rc<T>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where T: Tid<'a>,
Attempts to downcast self to
T
behind Rc
pointersource§fn downcast_arc<T>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Tid<'a>,
fn downcast_arc<T>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where T: Tid<'a>,
Attempts to downcast self to
T
behind Arc
pointer