Primitive type TypeDefinition
Implementations
impl TypeDefinition
pub comptime fn add_abi(self, abi_argument: CtString)
pub comptime fn as_type(self) -> Type
Return a syntactic version of this type definition as a type.
For example, type Foo<A, B> { ... }) would return Foo<A, B> when called with this method.
pub comptime fn as_type_with_generics(self, generics: [Type]) -> Option<Type>
Return this type applied to the given generic arguments.
For example, given type Foo<A, B> { ... }) could be applied to [quote[i32].as_type(), quote[Field].as_type()].as_vector()
to return Foo<i32, Field>.
If an incorrect number of generic arguments are given, this function will return None. Otherwise, this function returns Some with the resulting type inside.
pub comptime fn has_named_attribute<let N: u32>(self, name: str<N>) -> bool
pub comptime fn named_attribute_args<let N: u32>(self, name: str<N>) -> [[Quoted]]
pub comptime fn has_builtin_attribute<let N: u32>(self, name: str<N>) -> bool
pub comptime fn location(self) -> Location
pub comptime fn generics(self) -> [TypeGeneric]
Return each generic in this type definition.
pub comptime fn fields(self, generic_args: [Type]) -> [StructField]
Returns each field in this type. Any generic types used in each field type is automatically substituted with the provided generic arguments.
pub comptime fn fields_as_written(self) -> [StructField]
Returns each field in this type. Each type is as-is with any generic arguments
unchanged. Unless the field types are not needed, users should generally prefer
to use TypeDefinition::fields over this function if possible.
pub comptime fn module(self) -> Module
pub comptime fn name(self) -> Quoted
Trait implementations
impl Eq for TypeDefinition
pub comptime fn eq(self, other: Self) -> bool
impl Hash for TypeDefinition
pub comptime fn hash<H>(self, state: &mut H)
where
H: Hasher
A compile-time type which represents a type definition such as
struct Foo { ... }.A
TypeDefinitionis passed as the first argument to a macro attribute on top of a struct: