pub trait Visitor<'a>: Sized {
type Result: VisitorResult = ();
Show 56 methods
// Provided methods
fn visit_ident(&mut self, _: &'a Ident) -> Self::Result { ... }
fn visit_anon_const(&mut self, node: &'a AnonConst) -> Self::Result { ... }
fn visit_arm(&mut self, node: &'a Arm) -> Self::Result { ... }
fn visit_assoc_item_constraint(
&mut self,
node: &'a AssocItemConstraint,
) -> Self::Result { ... }
fn visit_attribute(&mut self, node: &'a Attribute) -> Self::Result { ... }
fn visit_block(&mut self, node: &'a Block) -> Self::Result { ... }
fn visit_capture_by(&mut self, node: &'a CaptureBy) -> Self::Result { ... }
fn visit_closure_binder(&mut self, node: &'a ClosureBinder) -> Self::Result { ... }
fn visit_contract(&mut self, node: &'a FnContract) -> Self::Result { ... }
fn visit_coroutine_kind(&mut self, node: &'a CoroutineKind) -> Self::Result { ... }
fn visit_crate(&mut self, node: &'a Crate) -> Self::Result { ... }
fn visit_expr(&mut self, node: &'a Expr) -> Self::Result { ... }
fn visit_expr_field(&mut self, node: &'a ExprField) -> Self::Result { ... }
fn visit_field_def(&mut self, node: &'a FieldDef) -> Self::Result { ... }
fn visit_fn_decl(&mut self, node: &'a FnDecl) -> Self::Result { ... }
fn visit_fn_header(&mut self, node: &'a FnHeader) -> Self::Result { ... }
fn visit_fn_ret_ty(&mut self, node: &'a FnRetTy) -> Self::Result { ... }
fn visit_foreign_mod(&mut self, node: &'a ForeignMod) -> Self::Result { ... }
fn visit_format_args(&mut self, node: &'a FormatArgs) -> Self::Result { ... }
fn visit_generic_arg(&mut self, node: &'a GenericArg) -> Self::Result { ... }
fn visit_generic_args(&mut self, node: &'a GenericArgs) -> Self::Result { ... }
fn visit_generic_param(&mut self, node: &'a GenericParam) -> Self::Result { ... }
fn visit_generics(&mut self, node: &'a Generics) -> Self::Result { ... }
fn visit_inline_asm(&mut self, node: &'a InlineAsm) -> Self::Result { ... }
fn visit_inline_asm_sym(&mut self, node: &'a InlineAsmSym) -> Self::Result { ... }
fn visit_label(&mut self, node: &'a Label) -> Self::Result { ... }
fn visit_lifetime(
&mut self,
node: &'a Lifetime,
_ctxt: LifetimeCtxt,
) -> Self::Result { ... }
fn visit_local(&mut self, node: &'a Local) -> Self::Result { ... }
fn visit_mac_call(&mut self, node: &'a MacCall) -> Self::Result { ... }
fn visit_macro_def(&mut self, node: &'a MacroDef) -> Self::Result { ... }
fn visit_param_bound(
&mut self,
node: &'a GenericBound,
_ctxt: BoundKind,
) -> Self::Result { ... }
fn visit_param(&mut self, node: &'a Param) -> Self::Result { ... }
fn visit_pat_field(&mut self, node: &'a PatField) -> Self::Result { ... }
fn visit_path(&mut self, node: &'a Path) -> Self::Result { ... }
fn visit_path_segment(&mut self, node: &'a PathSegment) -> Self::Result { ... }
fn visit_pat(&mut self, node: &'a Pat) -> Self::Result { ... }
fn visit_poly_trait_ref(&mut self, node: &'a PolyTraitRef) -> Self::Result { ... }
fn visit_precise_capturing_arg(
&mut self,
node: &'a PreciseCapturingArg,
) -> Self::Result { ... }
fn visit_qself(&mut self, node: &'a QSelf) -> Self::Result { ... }
fn visit_trait_ref(&mut self, node: &'a TraitRef) -> Self::Result { ... }
fn visit_ty_pat(&mut self, node: &'a TyPat) -> Self::Result { ... }
fn visit_ty(&mut self, node: &'a Ty) -> Self::Result { ... }
fn visit_use_tree(&mut self, node: &'a UseTree) -> Self::Result { ... }
fn visit_variant_data(&mut self, node: &'a VariantData) -> Self::Result { ... }
fn visit_variant(&mut self, node: &'a Variant) -> Self::Result { ... }
fn visit_vis(&mut self, node: &'a Visibility) -> Self::Result { ... }
fn visit_where_predicate_kind(
&mut self,
node: &'a WherePredicateKind,
) -> Self::Result { ... }
fn visit_where_predicate(
&mut self,
node: &'a WherePredicate,
) -> Self::Result { ... }
fn visit_id(&mut self, _id: NodeId) -> Self::Result { ... }
fn visit_method_receiver_expr(&mut self, ex: &'a Expr) -> Self::Result { ... }
fn visit_item(&mut self, item: &'a Item) -> Self::Result { ... }
fn visit_foreign_item(&mut self, item: &'a ForeignItem) -> Self::Result { ... }
fn visit_assoc_item(
&mut self,
item: &'a AssocItem,
ctxt: AssocCtxt,
) -> Self::Result { ... }
fn visit_fn(&mut self, fk: FnKind<'a>, _: Span, _: NodeId) -> Self::Result { ... }
fn visit_stmt(&mut self, s: &'a Stmt) -> Self::Result { ... }
fn visit_nested_use_tree(
&mut self,
use_tree: &'a UseTree,
id: NodeId,
) -> Self::Result { ... }
}
Expand description
Each method of this trait is a hook to be potentially
overridden. Each method’s default implementation recursively visits
the substructure of the input via the corresponding walk
method;
e.g., the visit_item
method by default calls visit::walk_item
.
If you want to ensure that your code handles every variant explicitly, you need to override each method. (And you also need to monitor future changes to this trait in case a new method with a new default implementation gets introduced.)
Every walk_*
method uses deconstruction to access fields of structs and
enums. This will result in a compile error if a field is added, which makes
it more likely the appropriate visit call will be added for it.
Provided Associated Types§
Sourcetype Result: VisitorResult = ()
type Result: VisitorResult = ()
The result type of the visit_*
methods. Can be either ()
,
or ControlFlow<T>
.
Provided Methods§
fn visit_ident(&mut self, _: &'a Ident) -> Self::Result
fn visit_anon_const(&mut self, node: &'a AnonConst) -> Self::Result
fn visit_arm(&mut self, node: &'a Arm) -> Self::Result
fn visit_assoc_item_constraint( &mut self, node: &'a AssocItemConstraint, ) -> Self::Result
fn visit_attribute(&mut self, node: &'a Attribute) -> Self::Result
fn visit_block(&mut self, node: &'a Block) -> Self::Result
fn visit_capture_by(&mut self, node: &'a CaptureBy) -> Self::Result
fn visit_closure_binder(&mut self, node: &'a ClosureBinder) -> Self::Result
fn visit_contract(&mut self, node: &'a FnContract) -> Self::Result
fn visit_coroutine_kind(&mut self, node: &'a CoroutineKind) -> Self::Result
fn visit_crate(&mut self, node: &'a Crate) -> Self::Result
fn visit_expr(&mut self, node: &'a Expr) -> Self::Result
fn visit_expr_field(&mut self, node: &'a ExprField) -> Self::Result
fn visit_field_def(&mut self, node: &'a FieldDef) -> Self::Result
fn visit_fn_decl(&mut self, node: &'a FnDecl) -> Self::Result
fn visit_fn_header(&mut self, node: &'a FnHeader) -> Self::Result
fn visit_fn_ret_ty(&mut self, node: &'a FnRetTy) -> Self::Result
fn visit_foreign_mod(&mut self, node: &'a ForeignMod) -> Self::Result
fn visit_format_args(&mut self, node: &'a FormatArgs) -> Self::Result
fn visit_generic_arg(&mut self, node: &'a GenericArg) -> Self::Result
fn visit_generic_args(&mut self, node: &'a GenericArgs) -> Self::Result
fn visit_generic_param(&mut self, node: &'a GenericParam) -> Self::Result
fn visit_generics(&mut self, node: &'a Generics) -> Self::Result
fn visit_inline_asm(&mut self, node: &'a InlineAsm) -> Self::Result
fn visit_inline_asm_sym(&mut self, node: &'a InlineAsmSym) -> Self::Result
fn visit_label(&mut self, node: &'a Label) -> Self::Result
fn visit_lifetime( &mut self, node: &'a Lifetime, _ctxt: LifetimeCtxt, ) -> Self::Result
fn visit_local(&mut self, node: &'a Local) -> Self::Result
fn visit_mac_call(&mut self, node: &'a MacCall) -> Self::Result
fn visit_macro_def(&mut self, node: &'a MacroDef) -> Self::Result
fn visit_param_bound( &mut self, node: &'a GenericBound, _ctxt: BoundKind, ) -> Self::Result
fn visit_param(&mut self, node: &'a Param) -> Self::Result
fn visit_pat_field(&mut self, node: &'a PatField) -> Self::Result
fn visit_path(&mut self, node: &'a Path) -> Self::Result
fn visit_path_segment(&mut self, node: &'a PathSegment) -> Self::Result
fn visit_pat(&mut self, node: &'a Pat) -> Self::Result
fn visit_poly_trait_ref(&mut self, node: &'a PolyTraitRef) -> Self::Result
fn visit_precise_capturing_arg( &mut self, node: &'a PreciseCapturingArg, ) -> Self::Result
fn visit_qself(&mut self, node: &'a QSelf) -> Self::Result
fn visit_trait_ref(&mut self, node: &'a TraitRef) -> Self::Result
fn visit_ty_pat(&mut self, node: &'a TyPat) -> Self::Result
fn visit_ty(&mut self, node: &'a Ty) -> Self::Result
fn visit_use_tree(&mut self, node: &'a UseTree) -> Self::Result
fn visit_variant_data(&mut self, node: &'a VariantData) -> Self::Result
fn visit_variant(&mut self, node: &'a Variant) -> Self::Result
fn visit_vis(&mut self, node: &'a Visibility) -> Self::Result
fn visit_where_predicate_kind( &mut self, node: &'a WherePredicateKind, ) -> Self::Result
fn visit_where_predicate(&mut self, node: &'a WherePredicate) -> Self::Result
fn visit_id(&mut self, _id: NodeId) -> Self::Result
Sourcefn visit_method_receiver_expr(&mut self, ex: &'a Expr) -> Self::Result
fn visit_method_receiver_expr(&mut self, ex: &'a Expr) -> Self::Result
This method is a hack to workaround unstable of stmt_expr_attributes
.
It can be removed once that feature is stabilized.
fn visit_item(&mut self, item: &'a Item) -> Self::Result
fn visit_foreign_item(&mut self, item: &'a ForeignItem) -> Self::Result
fn visit_assoc_item( &mut self, item: &'a AssocItem, ctxt: AssocCtxt, ) -> Self::Result
fn visit_fn(&mut self, fk: FnKind<'a>, _: Span, _: NodeId) -> Self::Result
fn visit_stmt(&mut self, s: &'a Stmt) -> Self::Result
fn visit_nested_use_tree( &mut self, use_tree: &'a UseTree, id: NodeId, ) -> Self::Result
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.