TypeDecl
class TypeDecl Import
Source: use macro::{TypeDecl}; compiler/src/prelude/macro.hy A class or enum declaration handed to a derive or attribute macro.
Fields#
| Field | Type | Description |
|---|---|---|
name | Ident | |
kind | string | "class" or "enum". |
generics | Vec<Ident> | |
field_list | Vec<Field> | |
variant_list | Vec<Variant> | |
attrs | Vec<Attr> | |
repr | string | #[repr(...)] backing ("int", …) or the inferred scalar backing, else "". |
module | string | Module path the declaration lives in ("" for the entry file). |
docs | Vec<string> | |
source | string | The declaration as written (an attribute macro’s own attribute removed). |
Methods#
| Name | Description |
|---|---|
is_class | |
self_type | The type as written in a signature: Name, or Name<T, U> for a generic type. |
impl_head | Head of an impl Trait for … for this type: Name, or for a generic type Name<T: bound, U: bound>, every type parameter bounded by bound ("Show", "Ord + Eq"). |
is_enum | |
fields | Class fields (empty for an enum). |
variants | Enum variants (empty for a class). |
has_attr | |
attr_str |
See also#
Code: Generated coil source: declarations, an expression, statements or a type.Ident: A name as written in source.Expr: A function-style macro argument as written:f(1),a + b,"text".TypeRef: A type annotation as written (not resolved):Vec<int>,json::Value.AttrArg: Onekey = value(or positionalvalue, withkey == "") attribute argument.Attr:#[name(args)]on a declaration, field or variant.Field: A class field, or a field of a record enum variant.Variant: One enum variant.