pub trait Visit {
Show 21 methods
// Required methods
fn visit_post<F>(&self, f: &mut F) -> Result<(), RecursionLimitError>
where F: FnMut(&Self);
fn visit_post_nolimit<F>(&self, f: &mut F)
where F: FnMut(&Self);
fn visit_mut_post<F>(
&mut self,
f: &mut F,
) -> Result<(), RecursionLimitError>
where F: FnMut(&mut Self);
fn visit_mut_post_nolimit<F>(&mut self, f: &mut F)
where F: FnMut(&mut Self);
fn try_visit_post<F, E>(&self, f: &mut F) -> Result<(), E>
where F: FnMut(&Self) -> Result<(), E>,
E: From<RecursionLimitError>;
fn try_visit_mut_post<F, E>(&mut self, f: &mut F) -> Result<(), E>
where F: FnMut(&mut Self) -> Result<(), E>,
E: From<RecursionLimitError>;
fn visit_pre<F>(&self, f: &mut F) -> Result<(), RecursionLimitError>
where F: FnMut(&Self);
fn visit_pre_with_context<Context, AccFun, Visitor>(
&self,
init: Context,
acc_fun: &mut AccFun,
visitor: &mut Visitor,
) -> Result<(), RecursionLimitError>
where Context: Clone,
AccFun: FnMut(Context, &Self) -> Context,
Visitor: FnMut(&Context, &Self);
fn visit_pre_nolimit<F>(&self, f: &mut F)
where F: FnMut(&Self);
fn visit_mut_pre<F>(&mut self, f: &mut F) -> Result<(), RecursionLimitError>
where F: FnMut(&mut Self);
fn visit_mut_pre_nolimit<F>(&mut self, f: &mut F)
where F: FnMut(&mut Self);
fn try_visit_pre<F, E>(&self, f: &mut F) -> Result<(), E>
where F: FnMut(&Self) -> Result<(), E>,
E: From<RecursionLimitError>;
fn try_visit_mut_pre<F, E>(&mut self, f: &mut F) -> Result<(), E>
where F: FnMut(&mut Self) -> Result<(), E>,
E: From<RecursionLimitError>;
fn visit_pre_post<F1, F2>(
&self,
pre: &mut F1,
post: &mut F2,
) -> Result<(), RecursionLimitError>
where F1: FnMut(&Self) -> Option<Vec<&Self>>,
F2: FnMut(&Self);
fn visit_pre_post_nolimit<F1, F2>(&self, pre: &mut F1, post: &mut F2)
where F1: FnMut(&Self) -> Option<Vec<&Self>>,
F2: FnMut(&Self);
fn visit_mut_pre_post<F1, F2>(
&mut self,
pre: &mut F1,
post: &mut F2,
) -> Result<(), RecursionLimitError>
where F1: FnMut(&mut Self) -> Option<Vec<&mut Self>>,
F2: FnMut(&mut Self);
fn visit_mut_pre_post_nolimit<F1, F2>(
&mut self,
pre: &mut F1,
post: &mut F2,
)
where F1: FnMut(&mut Self) -> Option<Vec<&mut Self>>,
F2: FnMut(&mut Self);
fn visit<V>(&self, visitor: &mut V) -> Result<(), RecursionLimitError>
where Self: Sized,
V: Visitor<Self>;
fn visit_mut<V>(
&mut self,
visitor: &mut V,
) -> Result<(), RecursionLimitError>
where Self: Sized,
V: VisitorMut<Self>;
fn try_visit<V, E>(&self, visitor: &mut V) -> Result<(), E>
where Self: Sized,
V: TryVisitor<Self, E>,
E: From<RecursionLimitError>;
fn try_visit_mut<V, E>(&mut self, visitor: &mut V) -> Result<(), E>
where Self: Sized,
V: TryVisitorMut<Self, E>,
E: From<RecursionLimitError>;
}Expand description
A trait for types that can recursively visit their children of the same type.
This trait is automatically implemented for all implementors of
VisitChildren.
All methods provided by this trait ensure that the stack is grown
as needed, to avoid stack overflows when traversing deeply
recursive objects. They also enforce a recursion limit of
RECURSION_LIMIT by returning an error when that limit
is exceeded.
There are also *_nolimit methods that donโt enforce a recursion
limit. Those methods are deprecated and should not be used.
Required Methodsยง
Sourcefn visit_post<F>(&self, f: &mut F) -> Result<(), RecursionLimitError>where
F: FnMut(&Self),
fn visit_post<F>(&self, f: &mut F) -> Result<(), RecursionLimitError>where
F: FnMut(&Self),
Post-order immutable infallible visitor for self.
Sourcefn visit_post_nolimit<F>(&self, f: &mut F)where
F: FnMut(&Self),
๐Deprecated: Use visit_post instead.
fn visit_post_nolimit<F>(&self, f: &mut F)where
F: FnMut(&Self),
visit_post instead.Post-order immutable infallible visitor for self.
Does not enforce a recursion limit.
Sourcefn visit_mut_post<F>(&mut self, f: &mut F) -> Result<(), RecursionLimitError>where
F: FnMut(&mut Self),
fn visit_mut_post<F>(&mut self, f: &mut F) -> Result<(), RecursionLimitError>where
F: FnMut(&mut Self),
Post-order mutable infallible visitor for self.
Sourcefn visit_mut_post_nolimit<F>(&mut self, f: &mut F)where
F: FnMut(&mut Self),
๐Deprecated: Use visit_mut_post instead.
fn visit_mut_post_nolimit<F>(&mut self, f: &mut F)where
F: FnMut(&mut Self),
visit_mut_post instead.Post-order mutable infallible visitor for self.
Does not enforce a recursion limit.
Sourcefn try_visit_post<F, E>(&self, f: &mut F) -> Result<(), E>
fn try_visit_post<F, E>(&self, f: &mut F) -> Result<(), E>
Post-order immutable fallible visitor for self.
Sourcefn try_visit_mut_post<F, E>(&mut self, f: &mut F) -> Result<(), E>
fn try_visit_mut_post<F, E>(&mut self, f: &mut F) -> Result<(), E>
Post-order mutable fallible visitor for self.
Sourcefn visit_pre<F>(&self, f: &mut F) -> Result<(), RecursionLimitError>where
F: FnMut(&Self),
fn visit_pre<F>(&self, f: &mut F) -> Result<(), RecursionLimitError>where
F: FnMut(&Self),
Pre-order immutable infallible visitor for self.
Sourcefn visit_pre_with_context<Context, AccFun, Visitor>(
&self,
init: Context,
acc_fun: &mut AccFun,
visitor: &mut Visitor,
) -> Result<(), RecursionLimitError>
fn visit_pre_with_context<Context, AccFun, Visitor>( &self, init: Context, acc_fun: &mut AccFun, visitor: &mut Visitor, ) -> Result<(), RecursionLimitError>
Pre-order immutable infallible visitor for self, which also accumulates context
information along the path from the root to the current nodeโs parent.
acc_fun is a similar closure as in fold. The accumulated context is passed to the
visitor, along with the current node.
For example, one can use this on a MirScalarExpr to tell the visitor whether the current
subexpression has a negation somewhere above it.
When using it on a MirRelationExpr, one has to be mindful that Let bindings are not
followed, i.e., the context wonโt include what happens with a Let binding in some other
MirRelationExpr where the binding occurs in a Get.
Sourcefn visit_pre_nolimit<F>(&self, f: &mut F)where
F: FnMut(&Self),
๐Deprecated: Use visit_pre instead.
fn visit_pre_nolimit<F>(&self, f: &mut F)where
F: FnMut(&Self),
visit_pre instead.Pre-order immutable infallible visitor for self.
Does not enforce a recursion limit.
Sourcefn visit_mut_pre<F>(&mut self, f: &mut F) -> Result<(), RecursionLimitError>where
F: FnMut(&mut Self),
fn visit_mut_pre<F>(&mut self, f: &mut F) -> Result<(), RecursionLimitError>where
F: FnMut(&mut Self),
Pre-order mutable infallible visitor for self.
Sourcefn visit_mut_pre_nolimit<F>(&mut self, f: &mut F)where
F: FnMut(&mut Self),
๐Deprecated: Use visit_mut_pre instead.
fn visit_mut_pre_nolimit<F>(&mut self, f: &mut F)where
F: FnMut(&mut Self),
visit_mut_pre instead.Pre-order mutable infallible visitor for self.
Does not enforce a recursion limit.
Sourcefn try_visit_pre<F, E>(&self, f: &mut F) -> Result<(), E>
fn try_visit_pre<F, E>(&self, f: &mut F) -> Result<(), E>
Pre-order immutable fallible visitor for self.
Sourcefn try_visit_mut_pre<F, E>(&mut self, f: &mut F) -> Result<(), E>
fn try_visit_mut_pre<F, E>(&mut self, f: &mut F) -> Result<(), E>
Pre-order mutable fallible visitor for self.
Sourcefn visit_pre_post<F1, F2>(
&self,
pre: &mut F1,
post: &mut F2,
) -> Result<(), RecursionLimitError>
fn visit_pre_post<F1, F2>( &self, pre: &mut F1, post: &mut F2, ) -> Result<(), RecursionLimitError>
A generalization of Visit::visit_pre and Visit::visit_post.
The function pre runs on self before it runs on any of the children.
The function post runs on children first before the parent.
Optionally, pre can return which children, if any, should be visited
(default is to visit all children).
Sourcefn visit_pre_post_nolimit<F1, F2>(&self, pre: &mut F1, post: &mut F2)
๐Deprecated: Use visit instead.
fn visit_pre_post_nolimit<F1, F2>(&self, pre: &mut F1, post: &mut F2)
visit instead.A generalization of Visit::visit_pre and Visit::visit_post.
Does not enforce a recursion limit.
The function pre runs on self before it runs on any of the children.
The function post runs on children first before the parent.
Optionally, pre can return which children, if any, should be visited
(default is to visit all children).
Sourcefn visit_mut_pre_post<F1, F2>(
&mut self,
pre: &mut F1,
post: &mut F2,
) -> Result<(), RecursionLimitError>
๐Deprecated: Use visit_mut instead.
fn visit_mut_pre_post<F1, F2>( &mut self, pre: &mut F1, post: &mut F2, ) -> Result<(), RecursionLimitError>
visit_mut instead.A generalization of Visit::visit_mut_pre and Visit::visit_mut_post.
The function pre runs on self before it runs on any of the children.
The function post runs on children first before the parent.
Optionally, pre can return which children, if any, should be visited
(default is to visit all children).
Sourcefn visit_mut_pre_post_nolimit<F1, F2>(&mut self, pre: &mut F1, post: &mut F2)
๐Deprecated: Use visit_mut_pre_post instead.
fn visit_mut_pre_post_nolimit<F1, F2>(&mut self, pre: &mut F1, post: &mut F2)
visit_mut_pre_post instead.A generalization of Visit::visit_mut_pre and Visit::visit_mut_post.
Does not enforce a recursion limit.
The function pre runs on self before it runs on any of the children.
The function post runs on children first before the parent.
Optionally, pre can return which children, if any, should be visited
(default is to visit all children).
fn visit<V>(&self, visitor: &mut V) -> Result<(), RecursionLimitError>
fn visit_mut<V>(&mut self, visitor: &mut V) -> Result<(), RecursionLimitError>where
Self: Sized,
V: VisitorMut<Self>,
fn try_visit<V, E>(&self, visitor: &mut V) -> Result<(), E>
fn try_visit_mut<V, E>(&mut self, visitor: &mut V) -> Result<(), E>
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.