pub trait Visitor<'a>: Sized {
type Result: VisitorResult = ();
Show 56 methods
// Provided methods
fn visit_ident(&mut self, _: &'a Ident) -> Self::Result { ... }
fn visit_foreign_mod(&mut self, nm: &'a ForeignMod) -> Self::Result { ... }
fn visit_foreign_item(&mut self, i: &'a ForeignItem) -> Self::Result { ... }
fn visit_item(&mut self, i: &'a Item) -> Self::Result { ... }
fn visit_local(&mut self, l: &'a Local) -> Self::Result { ... }
fn visit_block(&mut self, b: &'a Block) -> Self::Result { ... }
fn visit_param(&mut self, param: &'a Param) -> Self::Result { ... }
fn visit_arm(&mut self, a: &'a Arm) -> Self::Result { ... }
fn visit_pat(&mut self, p: &'a Pat) -> Self::Result { ... }
fn visit_anon_const(&mut self, c: &'a AnonConst) -> Self::Result { ... }
fn visit_expr(&mut self, ex: &'a Expr) -> Self::Result { ... }
fn visit_method_receiver_expr(&mut self, ex: &'a Expr) -> Self::Result { ... }
fn visit_ty(&mut self, t: &'a Ty) -> Self::Result { ... }
fn visit_ty_pat(&mut self, t: &'a TyPat) -> Self::Result { ... }
fn visit_generic_param(&mut self, param: &'a GenericParam) -> Self::Result { ... }
fn visit_generics(&mut self, g: &'a Generics) -> Self::Result { ... }
fn visit_closure_binder(&mut self, b: &'a ClosureBinder) -> Self::Result { ... }
fn visit_contract(&mut self, c: &'a FnContract) -> Self::Result { ... }
fn visit_where_predicate(&mut self, p: &'a WherePredicate) -> Self::Result { ... }
fn visit_where_predicate_kind(
&mut self,
k: &'a WherePredicateKind,
) -> Self::Result { ... }
fn visit_fn(&mut self, fk: FnKind<'a>, _: Span, _: NodeId) -> Self::Result { ... }
fn visit_assoc_item(
&mut self,
i: &'a AssocItem,
ctxt: AssocCtxt,
) -> Self::Result { ... }
fn visit_trait_ref(&mut self, t: &'a TraitRef) -> Self::Result { ... }
fn visit_param_bound(
&mut self,
bounds: &'a GenericBound,
_ctxt: BoundKind,
) -> Self::Result { ... }
fn visit_precise_capturing_arg(
&mut self,
arg: &'a PreciseCapturingArg,
) -> Self::Result { ... }
fn visit_poly_trait_ref(&mut self, t: &'a PolyTraitRef) -> Self::Result { ... }
fn visit_variant_data(&mut self, s: &'a VariantData) -> Self::Result { ... }
fn visit_field_def(&mut self, s: &'a FieldDef) -> Self::Result { ... }
fn visit_variant(&mut self, v: &'a Variant) -> Self::Result { ... }
fn visit_label(&mut self, label: &'a Label) -> Self::Result { ... }
fn visit_lifetime(
&mut self,
lifetime: &'a Lifetime,
_: LifetimeCtxt,
) -> Self::Result { ... }
fn visit_mac_call(&mut self, mac: &'a MacCall) -> Self::Result { ... }
fn visit_id(&mut self, _id: NodeId) -> Self::Result { ... }
fn visit_macro_def(&mut self, macro_def: &'a MacroDef) -> Self::Result { ... }
fn visit_path(&mut self, path: &'a Path) -> Self::Result { ... }
fn visit_use_tree(&mut self, use_tree: &'a UseTree) -> Self::Result { ... }
fn visit_path_segment(
&mut self,
path_segment: &'a PathSegment,
) -> Self::Result { ... }
fn visit_generic_args(
&mut self,
generic_args: &'a GenericArgs,
) -> Self::Result { ... }
fn visit_generic_arg(&mut self, generic_arg: &'a GenericArg) -> Self::Result { ... }
fn visit_assoc_item_constraint(
&mut self,
constraint: &'a AssocItemConstraint,
) -> Self::Result { ... }
fn visit_attribute(&mut self, attr: &'a Attribute) -> Self::Result { ... }
fn visit_vis(&mut self, vis: &'a Visibility) -> Self::Result { ... }
fn visit_fn_ret_ty(&mut self, ret_ty: &'a FnRetTy) -> Self::Result { ... }
fn visit_fn_header(&mut self, header: &'a FnHeader) -> Self::Result { ... }
fn visit_expr_field(&mut self, f: &'a ExprField) -> Self::Result { ... }
fn visit_pat_field(&mut self, fp: &'a PatField) -> Self::Result { ... }
fn visit_crate(&mut self, krate: &'a Crate) -> Self::Result { ... }
fn visit_inline_asm(&mut self, asm: &'a InlineAsm) -> Self::Result { ... }
fn visit_format_args(&mut self, fmt: &'a FormatArgs) -> Self::Result { ... }
fn visit_inline_asm_sym(&mut self, sym: &'a InlineAsmSym) -> Self::Result { ... }
fn visit_capture_by(&mut self, capture_by: &'a CaptureBy) -> Self::Result { ... }
fn visit_coroutine_kind(
&mut self,
coroutine_kind: &'a CoroutineKind,
) -> Self::Result { ... }
fn visit_fn_decl(&mut self, fn_decl: &'a FnDecl) -> Self::Result { ... }
fn visit_qself(&mut self, qs: &'a Option<P<QSelf>>) -> 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_foreign_mod(&mut self, nm: &'a ForeignMod) -> Self::Result
fn visit_foreign_item(&mut self, i: &'a ForeignItem) -> Self::Result
fn visit_item(&mut self, i: &'a Item) -> Self::Result
fn visit_local(&mut self, l: &'a Local) -> Self::Result
fn visit_block(&mut self, b: &'a Block) -> Self::Result
fn visit_param(&mut self, param: &'a Param) -> Self::Result
fn visit_arm(&mut self, a: &'a Arm) -> Self::Result
fn visit_pat(&mut self, p: &'a Pat) -> Self::Result
fn visit_anon_const(&mut self, c: &'a AnonConst) -> Self::Result
fn visit_expr(&mut self, ex: &'a Expr) -> 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_ty(&mut self, t: &'a Ty) -> Self::Result
fn visit_ty_pat(&mut self, t: &'a TyPat) -> Self::Result
fn visit_generic_param(&mut self, param: &'a GenericParam) -> Self::Result
fn visit_generics(&mut self, g: &'a Generics) -> Self::Result
fn visit_closure_binder(&mut self, b: &'a ClosureBinder) -> Self::Result
fn visit_contract(&mut self, c: &'a FnContract) -> Self::Result
fn visit_where_predicate(&mut self, p: &'a WherePredicate) -> Self::Result
fn visit_where_predicate_kind( &mut self, k: &'a WherePredicateKind, ) -> Self::Result
fn visit_fn(&mut self, fk: FnKind<'a>, _: Span, _: NodeId) -> Self::Result
fn visit_assoc_item( &mut self, i: &'a AssocItem, ctxt: AssocCtxt, ) -> Self::Result
fn visit_trait_ref(&mut self, t: &'a TraitRef) -> Self::Result
fn visit_param_bound( &mut self, bounds: &'a GenericBound, _ctxt: BoundKind, ) -> Self::Result
fn visit_precise_capturing_arg( &mut self, arg: &'a PreciseCapturingArg, ) -> Self::Result
fn visit_poly_trait_ref(&mut self, t: &'a PolyTraitRef) -> Self::Result
fn visit_variant_data(&mut self, s: &'a VariantData) -> Self::Result
fn visit_field_def(&mut self, s: &'a FieldDef) -> Self::Result
fn visit_variant(&mut self, v: &'a Variant) -> Self::Result
fn visit_label(&mut self, label: &'a Label) -> Self::Result
fn visit_lifetime( &mut self, lifetime: &'a Lifetime, _: LifetimeCtxt, ) -> Self::Result
fn visit_mac_call(&mut self, mac: &'a MacCall) -> Self::Result
fn visit_id(&mut self, _id: NodeId) -> Self::Result
fn visit_macro_def(&mut self, macro_def: &'a MacroDef) -> Self::Result
fn visit_path(&mut self, path: &'a Path) -> Self::Result
fn visit_use_tree(&mut self, use_tree: &'a UseTree) -> Self::Result
fn visit_path_segment(&mut self, path_segment: &'a PathSegment) -> Self::Result
fn visit_generic_args(&mut self, generic_args: &'a GenericArgs) -> Self::Result
fn visit_generic_arg(&mut self, generic_arg: &'a GenericArg) -> Self::Result
fn visit_assoc_item_constraint( &mut self, constraint: &'a AssocItemConstraint, ) -> Self::Result
fn visit_attribute(&mut self, attr: &'a Attribute) -> Self::Result
fn visit_vis(&mut self, vis: &'a Visibility) -> Self::Result
fn visit_fn_ret_ty(&mut self, ret_ty: &'a FnRetTy) -> Self::Result
fn visit_fn_header(&mut self, header: &'a FnHeader) -> Self::Result
fn visit_expr_field(&mut self, f: &'a ExprField) -> Self::Result
fn visit_pat_field(&mut self, fp: &'a PatField) -> Self::Result
fn visit_crate(&mut self, krate: &'a Crate) -> Self::Result
fn visit_inline_asm(&mut self, asm: &'a InlineAsm) -> Self::Result
fn visit_format_args(&mut self, fmt: &'a FormatArgs) -> Self::Result
fn visit_inline_asm_sym(&mut self, sym: &'a InlineAsmSym) -> Self::Result
fn visit_capture_by(&mut self, capture_by: &'a CaptureBy) -> Self::Result
fn visit_coroutine_kind( &mut self, coroutine_kind: &'a CoroutineKind, ) -> Self::Result
fn visit_fn_decl(&mut self, fn_decl: &'a FnDecl) -> Self::Result
fn visit_qself(&mut self, qs: &'a Option<P<QSelf>>) -> 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.