pub struct Body {
pub exprs: Arena<Expr>,
pub pats: Arena<Pat>,
pub bindings: Arena<Binding>,
pub labels: Arena<Label>,
pub binding_owners: FxHashMap<BindingId, ExprId>,
pub params: Box<[PatId]>,
pub self_param: Option<BindingId>,
pub body_expr: ExprId,
pub types: TypesMap,
/* private fields */
}
Expand description
The body of an item (function, const etc.).
Fields§
§exprs: Arena<Expr>
§pats: Arena<Pat>
§bindings: Arena<Binding>
§labels: Arena<Label>
§binding_owners: FxHashMap<BindingId, ExprId>
Id of the closure/coroutine that owns the corresponding binding. If a binding is owned by the top level expression, it will not be listed in here.
params: Box<[PatId]>
The patterns for the function’s parameters. While the parameter types are part of the function signature, the patterns are not (they don’t change the external type of the function).
If this Body
is for the body of a constant, this will just be
empty.
self_param: Option<BindingId>
§body_expr: ExprId
The ExprId
of the actual body expression.
types: TypesMap
Implementations§
source§impl Body
impl Body
sourcepub fn blocks<'a>(
&'a self,
db: &'a dyn DefDatabase,
) -> impl Iterator<Item = (BlockId, Arc<DefMap>)> + 'a
pub fn blocks<'a>( &'a self, db: &'a dyn DefDatabase, ) -> impl Iterator<Item = (BlockId, Arc<DefMap>)> + 'a
Returns an iterator over all block expressions in this body that define inner items.
pub fn pretty_print( &self, db: &dyn DefDatabase, owner: DefWithBodyId, edition: Edition, ) -> String
pub fn pretty_print_expr( &self, db: &dyn DefDatabase, owner: DefWithBodyId, expr: ExprId, edition: Edition, ) -> String
pub fn pretty_print_pat( &self, db: &dyn DefDatabase, owner: DefWithBodyId, pat: PatId, oneline: bool, edition: Edition, ) -> String
pub fn walk_bindings_in_pat(&self, pat_id: PatId, f: impl FnMut(BindingId))
pub fn walk_pats_shallow(&self, pat_id: PatId, f: impl FnMut(PatId))
pub fn walk_pats(&self, pat_id: PatId, f: &mut impl FnMut(PatId))
pub fn is_binding_upvar(&self, binding: BindingId, relative_to: ExprId) -> bool
pub fn walk_child_exprs(&self, expr_id: ExprId, f: impl FnMut(ExprId))
pub fn walk_child_exprs_without_pats( &self, expr_id: ExprId, f: impl FnMut(ExprId), )
pub fn walk_exprs_in_pat(&self, pat_id: PatId, f: &mut impl FnMut(ExprId))
pub fn expr_path_hygiene(&self, expr: ExprId) -> HygieneId
pub fn pat_path_hygiene(&self, pat: PatId) -> HygieneId
pub fn expr_or_pat_path_hygiene(&self, id: ExprOrPatId) -> HygieneId
Trait Implementations§
impl Eq for Body
impl StructuralPartialEq for Body
Auto Trait Implementations§
impl Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnwindSafe for Body
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more