Body in rustc_hir::hir - Rust (original) (raw)

pub struct Body<'hir> {
    pub params: &'hir [Param<'hir>],
    pub value: &'hir Expr<'hir>,
}

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:

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

§

§

§

§

§

§

§

§

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