Struct rustc_hir::Body[][src]

pub struct Body<'hir> {
    pub params: &'hir [Param<'hir>],
    pub value: Expr<'hir>,
    pub generator_kind: Option<GeneratorKind>,
}
Expand description

The body of a function, closure, or constant value. In the case of a function, the body contains not only the function body itself (which is an expression), but also the argument patterns, since those are something that the caller doesn’t really care about.

Examples

fn foo((x, y): (u32, u32)) -> u32 {
    x + y
}

Here, the Body associated with foo() would contain:

  • an params array containing the (x, y) pattern
  • a value containing the x + y expression (maybe wrapped in a block)
  • generator_kind would be None

All bodies have an owner, which can be accessed via the HIR map using body_owner_def_id().

Fields

params: &'hir [Param<'hir>]value: Expr<'hir>generator_kind: Option<GeneratorKind>

Implementations

Trait Implementations

Formats the value using the given formatter. 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

Performs the conversion.

Performs the conversion.

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 be different between compiler versions and platforms. 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: 88 bytes