pub enum DefKind {
Show 32 variants Mod, Struct, Union, Enum, Variant, Trait, TyAlias, ForeignTy, TraitAlias, AssocTy, TyParam, Fn, Const, ConstParam, Static(Mutability), Ctor(CtorOfCtorKind), AssocFn, AssocConst, Macro(MacroKind), ExternCrate, Use, ForeignMod, AnonConst, InlineConst, OpaqueTy, ImplTraitPlaceholder, Field, LifetimeParam, GlobalAsm, Impl, Closure, Generator,
}
Expand description

What kind of definition something is; e.g., mod vs struct.

Variants

Mod

Struct

Refers to the struct itself, DefKind::Ctor refers to its constructor if it exists.

Union

Enum

Variant

Refers to the variant itself, DefKind::Ctor refers to its constructor if it exists.

Trait

TyAlias

Type alias: type Foo = Bar;

ForeignTy

Type from an extern block.

TraitAlias

Trait alias: trait IntIterator = Iterator<Item = i32>;

AssocTy

Associated type: trait MyTrait { type Assoc; }

TyParam

Type parameter: the T in struct Vec<T> { ... }

Fn

Const

ConstParam

Constant generic parameter: struct Foo<const N: usize> { ... }

Static(Mutability)

Ctor(CtorOfCtorKind)

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.

AssocFn

Associated function: impl MyStruct { fn associated() {} } or trait Foo { fn associated() {} }

AssocConst

Associated constant: trait MyTrait { const ASSOC: usize; }

Macro(MacroKind)

ExternCrate

Use

ForeignMod

An extern block.

AnonConst

Anonymous constant, e.g. the 1 + 2 in [u8; 1 + 2]

InlineConst

An inline constant, e.g. const { 1 + 2 }

OpaqueTy

Opaque type, aka impl Trait.

ImplTraitPlaceholder

A return-position impl Trait in a trait definition

Field

LifetimeParam

Lifetime parameter: the 'a in struct Foo<'a> { ... }

GlobalAsm

A use of global_asm!.

Impl

Closure

Generator

Implementations

Gets an English article for the definition.

Whether query get_codegen_attrs should be used with this definition.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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: 2 bytes

Size for each variant:

  • Mod: 0 bytes
  • Struct: 0 bytes
  • Union: 0 bytes
  • Enum: 0 bytes
  • Variant: 0 bytes
  • Trait: 0 bytes
  • TyAlias: 0 bytes
  • ForeignTy: 0 bytes
  • TraitAlias: 0 bytes
  • AssocTy: 0 bytes
  • TyParam: 0 bytes
  • Fn: 0 bytes
  • Const: 0 bytes
  • ConstParam: 0 bytes
  • Static: 2 bytes
  • Ctor: 2 bytes
  • AssocFn: 0 bytes
  • AssocConst: 0 bytes
  • Macro: 2 bytes
  • ExternCrate: 0 bytes
  • Use: 0 bytes
  • ForeignMod: 0 bytes
  • AnonConst: 0 bytes
  • InlineConst: 0 bytes
  • OpaqueTy: 0 bytes
  • ImplTraitPlaceholder: 0 bytes
  • Field: 0 bytes
  • LifetimeParam: 0 bytes
  • GlobalAsm: 0 bytes
  • Impl: 0 bytes
  • Closure: 0 bytes
  • Generator: 0 bytes