Enum rustc_hir::def::DefKind [−][src]
pub enum DefKind {
Show 30 variants
Mod,
Struct,
Union,
Enum,
Variant,
Trait,
TyAlias,
ForeignTy,
TraitAlias,
AssocTy,
TyParam,
Fn,
Const,
ConstParam,
Static,
Ctor(CtorOf, CtorKind),
AssocFn,
AssocConst,
Macro(MacroKind),
ExternCrate,
Use,
ForeignMod,
AnonConst,
OpaqueTy,
Field,
LifetimeParam,
GlobalAsm,
Impl,
Closure,
Generator,
}
Expand description
What kind of definition something is; e.g., mod
vs struct
.
Variants
Refers to the struct itself, DefKind::Ctor
refers to its constructor if it exists.
Refers to the variant itself, DefKind::Ctor
refers to its constructor if it exists.
Type alias: type Foo = Bar;
Type from an extern
block.
Trait alias: trait IntIterator = Iterator<Item = i32>;
Associated type: trait MyTrait { type Assoc; }
Type parameter: the T
in struct Vec<T> { ... }
Constant generic parameter: struct Foo<const N: usize> { ... }
Refers to the struct or enum variant’s constructor.
The reason Ctor
exists in addition to DefKind::Struct
and
DefKind::Variant
is because structs and enum variants exist
in the type namespace, whereas struct and enum variant constructors
exist in the value namespace.
You may wonder why enum variants exist in the type namespace as opposed to the value namespace. Check out RFC 2593 for intuition on why that is.
Associated function: impl MyStruct { fn associated() {} }
Associated constant: trait MyTrait { const ASSOC: usize; }
Macro(MacroKind)
Tuple Fields of Macro
0: MacroKind
An extern
block.
Anonymous constant, e.g. the 1 + 2
in [u8; 1 + 2]
, or const { 1 + 2}
Opaque type, aka impl Trait
.
Lifetime parameter: the 'a
in struct Foo<'a> { ... }
A use of global_asm!
.
Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for DefKind
impl UnwindSafe for DefKind
Blanket Implementations
Mutably borrows from an owned value. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 3 bytes
Size for each variant:
Mod
: 0 bytesStruct
: 0 bytesUnion
: 0 bytesEnum
: 0 bytesVariant
: 0 bytesTrait
: 0 bytesTyAlias
: 0 bytesForeignTy
: 0 bytesTraitAlias
: 0 bytesAssocTy
: 0 bytesTyParam
: 0 bytesFn
: 0 bytesConst
: 0 bytesConstParam
: 0 bytesStatic
: 0 bytesCtor
: 2 bytesAssocFn
: 0 bytesAssocConst
: 0 bytesMacro
: 1 byteExternCrate
: 0 bytesUse
: 0 bytesForeignMod
: 0 bytesAnonConst
: 0 bytesOpaqueTy
: 0 bytesField
: 0 bytesLifetimeParam
: 0 bytesGlobalAsm
: 0 bytesImpl
: 0 bytesClosure
: 0 bytesGenerator
: 0 bytes