[][src]Module syn::visit

Syntax tree traversal to walk a shared borrow of a syntax tree.

Each method of the Visit trait is a hook that can be overridden to customize the behavior when visiting the corresponding type of node. By default, every method recursively visits the substructure of the input by invoking the right visitor method of each of its fields.

# use syn::{Attribute, BinOp, Expr, ExprBinary};
#
pub trait Visit<'ast> {
    /* ... */

    fn visit_expr_binary(&mut self, node: &'ast ExprBinary) {
        for attr in &node.attrs {
            self.visit_attribute(attr);
        }
        self.visit_expr(&*node.left);
        self.visit_bin_op(&node.op);
        self.visit_expr(&*node.right);
    }

    /* ... */
    # fn visit_attribute(&mut self, node: &'ast Attribute);
    # fn visit_expr(&mut self, node: &'ast Expr);
    # fn visit_bin_op(&mut self, node: &'ast BinOp);
}

This module is available if Syn is built with the "visit" feature.

Traits

Visit

Syntax tree traversal to walk a shared borrow of a syntax tree.

Functions

visit_abi
visit_angle_bracketed_generic_arguments
visit_attr_style
visit_attribute
visit_bare_fn_arg
visit_bare_fn_arg_name
visit_bin_op
visit_binding
visit_bound_lifetimes
visit_const_param
visit_constraint
visit_data
visit_data_enum
visit_data_struct
visit_data_union
visit_derive_input
visit_expr
visit_expr_binary
visit_expr_call
visit_expr_cast
visit_expr_field
visit_expr_index
visit_expr_lit
visit_expr_paren
visit_expr_path
visit_expr_unary
visit_expr_verbatim
visit_field
visit_fields
visit_fields_named
visit_fields_unnamed
visit_generic_argument
visit_generic_param
visit_generics
visit_ident
visit_index
visit_lifetime
visit_lifetime_def
visit_lit
visit_lit_bool
visit_lit_byte
visit_lit_byte_str
visit_lit_char
visit_lit_float
visit_lit_int
visit_lit_str
visit_lit_verbatim
visit_macro
visit_macro_delimiter
visit_member
visit_meta
visit_meta_list
visit_meta_name_value
visit_nested_meta
visit_parenthesized_generic_arguments
visit_path
visit_path_arguments
visit_path_segment
visit_predicate_eq
visit_predicate_lifetime
visit_predicate_type
visit_qself
visit_return_type
visit_span
visit_trait_bound
visit_trait_bound_modifier
visit_type
visit_type_array
visit_type_bare_fn
visit_type_group
visit_type_impl_trait
visit_type_infer
visit_type_macro
visit_type_never
visit_type_param
visit_type_param_bound
visit_type_paren
visit_type_path
visit_type_ptr
visit_type_reference
visit_type_slice
visit_type_trait_object
visit_type_tuple
visit_type_verbatim
visit_un_op
visit_variant
visit_vis_crate
visit_vis_public
visit_vis_restricted
visit_visibility
visit_where_clause
visit_where_predicate