Struct Body
pub struct Body {
pub store: ExpressionStore,
pub params: Box<[Idx<Pat>]>,
pub self_params: ArrayVec<Idx<Binding>, 2>,
}Expand description
The body of an item (function, const etc.).
Fields§
§store: ExpressionStore§params: Box<[Idx<Pat>]>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_params: ArrayVec<Idx<Binding>, 2>The first element, if it exists, is the real self binding.
The second element is used for async fn (or gen fn etc.). These functions
have to put a let self = self inside the returned coroutine, and the second element
points at it.
Implementations§
§impl Body
impl Body
pub fn with_source_map( db: &(dyn DefDatabase + 'static), def: DefWithBodyId, ) -> &(Arc<Body>, BodySourceMap)
pub fn of( db: &(dyn DefDatabase + 'static), def: DefWithBodyId, ) -> &<Arc<Body> as Deref>::Target
§impl Body
impl Body
pub fn root_expr(&self) -> Idx<Expr>
pub fn self_param(&self) -> Option<Idx<Binding>>
pub fn coroutine_self_binding(&self) -> Option<Idx<Binding>>
pub fn coroutine_self_binding(&self) -> Option<Idx<Binding>>
async fn (or gen fn etc.), have to put a let self = self inside the returned coroutine.
This function returns it.
pub fn pretty_print( &self, db: &(dyn DefDatabase + 'static), owner: DefWithBodyId, edition: Edition, ) -> String
pub fn pretty_print_expr( &self, db: &(dyn DefDatabase + 'static), owner: DefWithBodyId, expr: Idx<Expr>, edition: Edition, ) -> String
pub fn pretty_print_pat( &self, db: &(dyn DefDatabase + 'static), owner: DefWithBodyId, pat: Idx<Pat>, oneline: bool, edition: Edition, ) -> String
Methods from Deref<Target = ExpressionStore>§
pub fn expr_roots(&self) -> impl DoubleEndedIterator
pub fn expr_roots(&self) -> impl DoubleEndedIterator
Returns all expression root ExprIds found in this store.
pub fn find_root_for_expr(&self, expr: Idx<Expr>) -> Idx<Expr>
pub fn find_root_for_pat(&self, pat: Idx<Pat>) -> Idx<Expr>
pub fn find_root_for_binding(&self, binding: Idx<Binding>) -> Idx<Expr>
pub fn blocks<'a>(
&'a self,
db: &'a (dyn DefDatabase + 'static),
) -> impl Iterator<Item = (BlockId, &'a DefMap)> + 'a
pub fn blocks<'a>( &'a self, db: &'a (dyn DefDatabase + 'static), ) -> impl Iterator<Item = (BlockId, &'a DefMap)> + 'a
Returns an iterator over all block expressions in this store that define inner items.
pub fn walk_bindings_in_pat( &self, pat_id: Idx<Pat>, f: impl FnMut(Idx<Binding>), )
pub fn walk_pats_shallow(&self, pat_id: Idx<Pat>, f: impl FnMut(Idx<Pat>))
pub fn walk_pats(&self, pat_id: Idx<Pat>, f: &mut impl FnMut(Idx<Pat>))
pub fn is_binding_upvar( &self, binding: Idx<Binding>, relative_to: Idx<Expr>, ) -> bool
pub fn binding_owner(&self, id: Idx<Binding>) -> Option<Idx<Expr>>
pub fn walk_child_exprs(
&self,
expr_id: Idx<Expr>,
callback: impl FnMut(Idx<Expr>),
)
pub fn walk_child_exprs( &self, expr_id: Idx<Expr>, callback: impl FnMut(Idx<Expr>), )
Walks the immediate children expressions and calls f for each child expression.
pub fn walk_child_exprs_without_pats(
&self,
expr_id: Idx<Expr>,
callback: impl FnMut(Idx<Expr>),
)
pub fn walk_child_exprs_without_pats( &self, expr_id: Idx<Expr>, callback: impl FnMut(Idx<Expr>), )
Walks the immediate children expressions and calls f for each child expression but does
not walk expressions within patterns.
pub fn walk_exprs_in_pat(&self, pat_id: Idx<Pat>, f: impl FnMut(Idx<Expr>))
pub fn expr_path_hygiene(&self, expr: Idx<Expr>) -> HygieneId
pub fn pat_path_hygiene(&self, pat: Idx<Pat>) -> HygieneId
pub fn expr_or_pat_path_hygiene(&self, id: ExprOrPatId) -> HygieneId
pub fn exprs(&self) -> impl Iterator<Item = (Idx<Expr>, &Expr)>
pub fn pats(&self) -> impl Iterator<Item = (Idx<Pat>, &Pat)>
pub fn bindings(&self) -> impl Iterator<Item = (Idx<Binding>, &Binding)>
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 UnsafeUnpin 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
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§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
§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
key and return true if they are equal.§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
§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> ⓘ
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> ⓘ
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