pub struct Type<'a> {
pub type: MaybeBorrowed<'a, TokenCmpWrapper<Type>>,
pub generics_count: usize,
}
Expand description
A trait Generatable / Template. This asserts that some type implements some trait.
Fields§
§type: MaybeBorrowed<'a, TokenCmpWrapper<Type>>
The type to check the asserted type equals
generics_count: usize
The amount of generics the type should have
Implementations§
Source§impl<'a> Type<'a>
impl<'a> Type<'a>
Sourcepub fn new<T>(type: T, generics_count: usize) -> Self
pub fn new<T>(type: T, generics_count: usize) -> Self
Creates a new type template from some type to be checked against.
Takes any T that can be turned into a MaybeBorrowed
type, to support
references as well as owned types
pub fn from_owned(type: Type, generics_count: usize) -> Self
pub fn from_borrowed(type: &'a Type, generics_count: usize) -> Self
Trait Implementations§
Source§impl<'a> Generatable<'a, TokenCmpWrapper<StaticTid<Ident>>> for Type<'a>
impl<'a> Generatable<'a, TokenCmpWrapper<StaticTid<Ident>>> for Type<'a>
Source§const EMITS_NON_CONSTANT_CODE: bool = true
const EMITS_NON_CONSTANT_CODE: bool = true
Set this to true when any of the emitted code may be non-constant
Source§type GeneratableData = Ident
type GeneratableData = Ident
The type of any data passed from the
Generatable
stage to proceeding stages.Source§type TemplateData = ()
type TemplateData = ()
The type of any data passed from the
Template
stage to proceeding stages.Source§fn generatable(_: &mut Context<'_>) -> PassedData<Self::GeneratableData>
fn generatable(_: &mut Context<'_>) -> PassedData<Self::GeneratableData>
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§fn assert(
&self,
_context: &mut Context<'_>,
(assert_type_eq, _): (&Self::GeneratableData, &Self::TemplateData),
to_assert: &TokenCmpWrapper<StaticTid<Ident>>,
) -> Option<TokenStream>
fn assert( &self, _context: &mut Context<'_>, (assert_type_eq, _): (&Self::GeneratableData, &Self::TemplateData), to_assert: &TokenCmpWrapper<StaticTid<Ident>>, ) -> Option<TokenStream>
This is the method the
Assert
stage is composed of. Should return Tokens generated by this stage.Source§fn template(
&self,
_context: &mut Context<'_>,
_passed: &Self::GeneratableData,
) -> PassedData<Self::TemplateData>where
Self::TemplateData: Default,
fn template(
&self,
_context: &mut Context<'_>,
_passed: &Self::GeneratableData,
) -> PassedData<Self::TemplateData>where
Self::TemplateData: Default,
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§impl<'a> Generatable<'a, TokenCmpWrapper<Type>> for Type<'a>
impl<'a> Generatable<'a, TokenCmpWrapper<Type>> for Type<'a>
Source§const EMITS_NON_CONSTANT_CODE: bool = false
const EMITS_NON_CONSTANT_CODE: bool = false
Set this to true when any of the emitted code may be non-constant
Source§type GeneratableData = Ident
type GeneratableData = Ident
The type of any data passed from the
Generatable
stage to proceeding stages.Source§type TemplateData = ()
type TemplateData = ()
The type of any data passed from the
Template
stage to proceeding stages.Source§fn generatable(_: &mut Context<'_>) -> PassedData<Self::GeneratableData>
fn generatable(_: &mut Context<'_>) -> PassedData<Self::GeneratableData>
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§fn assert(
&self,
_context: &mut Context<'_>,
(assert_type_eq, _): (&Self::GeneratableData, &Self::TemplateData),
to_assert: &TokenCmpWrapper<Type>,
) -> Option<TokenStream>
fn assert( &self, _context: &mut Context<'_>, (assert_type_eq, _): (&Self::GeneratableData, &Self::TemplateData), to_assert: &TokenCmpWrapper<Type>, ) -> Option<TokenStream>
This is the method the
Assert
stage is composed of. Should return Tokens generated by this stage.Source§fn template(
&self,
_context: &mut Context<'_>,
_passed: &Self::GeneratableData,
) -> PassedData<Self::TemplateData>where
Self::TemplateData: Default,
fn template(
&self,
_context: &mut Context<'_>,
_passed: &Self::GeneratableData,
) -> PassedData<Self::TemplateData>where
Self::TemplateData: Default,
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§impl<'a> Ord for Type<'a>
impl<'a> Ord for Type<'a>
Source§impl<'a> PartialOrd for Type<'a>
impl<'a> PartialOrd for Type<'a>
impl<'a> Eq for Type<'a>
impl<'a> StructuralPartialEq for Type<'a>
impl<'a> TidAble<'a> for Type<'a>
Auto Trait Implementations§
impl<'a> Freeze for Type<'a>
impl<'a> RefUnwindSafe for Type<'a>
impl<'a> !Send for Type<'a>
impl<'a> !Sync for Type<'a>
impl<'a> Unpin for Type<'a>
impl<'a> UnwindSafe for Type<'a>
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
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, A> AttachGenericsWithAssert<'a, A> for Genwhere
Gen: Generatable<'a, A>,
A: 'a + TidAble<'a>,
impl<'a, Gen, A> AttachGenericsWithAssert<'a, A> for Genwhere
Gen: Generatable<'a, A>,
A: 'a + TidAble<'a>,
Source§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<B>(
self,
generics: Option<impl Into<MaybeBorrowed<'a, Generics>>>,
) -> WithGenerics<'a, <Gen as AttachGenericsWithAssert<'a, A>>::Output>where
B: TypeEq<This = A>,
Source§fn with_generics<B>(
self,
generics: impl Into<MaybeBorrowed<'a, Generics>>,
) -> WithGenerics<'a, Self::Output>
fn with_generics<B>( self, generics: impl Into<MaybeBorrowed<'a, Generics>>, ) -> WithGenerics<'a, Self::Output>
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, A> InsertIntoTemplate<'a, T, A> for T
impl<'a, T, A> InsertIntoTemplate<'a, T, A> for T
Source§fn test<B>(self, ty: impl Into<MaybeBorrowed<'a, A>>) -> Assert<'a, T, A>where
B: TypeEq<This = A>,
fn test<B>(self, ty: impl Into<MaybeBorrowed<'a, A>>) -> Assert<'a, T, A>where
B: TypeEq<This = A>,
Test some type against the template
Self
and turn
it into Self::Output
. So that the type may
either be borrowed or owned, any type that
can be turned into MaybeBorrowed<T::Assert>
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 X
impl<'a, X> TidExt<'a> for X
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<'b, T>(&'b self) -> Option<&'b T>where
T: Tid<'a>,
fn downcast_ref<'b, T>(&'b self) -> Option<&'b T>where
T: Tid<'a>,
Attempts to downcast self to
T
behind referenceSource§fn downcast_mut<'b, T>(&'b mut self) -> Option<&'b mut T>where
T: Tid<'a>,
fn downcast_mut<'b, T>(&'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