|
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `visit` mod in crate `syn`."><meta name="keywords" content="rust, rustlang, rust-lang, visit"><title>syn::visit - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../syn/index.html'><div class='logo-container'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Module visit</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'><a href='../index.html'>syn</a></p><script>window.sidebarCurrent = {name: 'visit', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../src/syn/gen/visit.rs.html#4-3372' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>syn</a>::<wbr><a class="mod" href=''>visit</a></span></h1><div class='docblock'><p>Syntax tree traversal to walk a shared borrow of a syntax tree.</p>
|
|
|
<p>Each method of the <a href="trait.Visit.html"><code>Visit</code></a> 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.</p>
|
|
|
<pre><code class="language-edition2018"># 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);
|
|
|
}
|
|
|
</code></pre>
|
|
|
<p><em>This module is available if Syn is built with the <code>"visit"</code> feature.</em></p>
|
|
|
</div><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
|
|
|
<table><tr class='module-item'><td><a class="trait" href="trait.Visit.html" title='syn::visit::Visit trait'>Visit</a></td><td class='docblock-short'><p>Syntax tree traversal to walk a shared borrow of a syntax tree.</p>
|
|
|
</td></tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
|
|
|
<table><tr class='module-item'><td><a class="fn" href="fn.visit_abi.html" title='syn::visit::visit_abi fn'>visit_abi</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_angle_bracketed_generic_arguments.html" title='syn::visit::visit_angle_bracketed_generic_arguments fn'>visit_angle_bracketed_generic_arguments</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_attr_style.html" title='syn::visit::visit_attr_style fn'>visit_attr_style</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_attribute.html" title='syn::visit::visit_attribute fn'>visit_attribute</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_bare_fn_arg.html" title='syn::visit::visit_bare_fn_arg fn'>visit_bare_fn_arg</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_bare_fn_arg_name.html" title='syn::visit::visit_bare_fn_arg_name fn'>visit_bare_fn_arg_name</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_bin_op.html" title='syn::visit::visit_bin_op fn'>visit_bin_op</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_binding.html" title='syn::visit::visit_binding fn'>visit_binding</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_bound_lifetimes.html" title='syn::visit::visit_bound_lifetimes fn'>visit_bound_lifetimes</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_const_param.html" title='syn::visit::visit_const_param fn'>visit_const_param</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_constraint.html" title='syn::visit::visit_constraint fn'>visit_constraint</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_data.html" title='syn::visit::visit_data fn'>visit_data</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_data_enum.html" title='syn::visit::visit_data_enum fn'>visit_data_enum</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_data_struct.html" title='syn::visit::visit_data_struct fn'>visit_data_struct</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_data_union.html" title='syn::visit::visit_data_union fn'>visit_data_union</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_derive_input.html" title='syn::visit::visit_derive_input fn'>visit_derive_input</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr.html" title='syn::visit::visit_expr fn'>visit_expr</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_binary.html" title='syn::visit::visit_expr_binary fn'>visit_expr_binary</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_call.html" title='syn::visit::visit_expr_call fn'>visit_expr_call</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_cast.html" title='syn::visit::visit_expr_cast fn'>visit_expr_cast</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_field.html" title='syn::visit::visit_expr_field fn'>visit_expr_field</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_index.html" title='syn::visit::visit_expr_index fn'>visit_expr_index</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_lit.html" title='syn::visit::visit_expr_lit fn'>visit_expr_lit</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_paren.html" title='syn::visit::visit_expr_paren fn'>visit_expr_paren</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_path.html" title='syn::visit::visit_expr_path fn'>visit_expr_path</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_unary.html" title='syn::visit::visit_expr_unary fn'>visit_expr_unary</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_expr_verbatim.html" title='syn::visit::visit_expr_verbatim fn'>visit_expr_verbatim</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_field.html" title='syn::visit::visit_field fn'>visit_field</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_fields.html" title='syn::visit::visit_fields fn'>visit_fields</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_fields_named.html" title='syn::visit::visit_fields_named fn'>visit_fields_named</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_fields_unnamed.html" title='syn::visit::visit_fields_unnamed fn'>visit_fields_unnamed</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_generic_argument.html" title='syn::visit::visit_generic_argument fn'>visit_generic_argument</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_generic_param.html" title='syn::visit::visit_generic_param fn'>visit_generic_param</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_generics.html" title='syn::visit::visit_generics fn'>visit_generics</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_ident.html" title='syn::visit::visit_ident fn'>visit_ident</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_index.html" title='syn::visit::visit_index fn'>visit_index</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lifetime.html" title='syn::visit::visit_lifetime fn'>visit_lifetime</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lifetime_def.html" title='syn::visit::visit_lifetime_def fn'>visit_lifetime_def</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit.html" title='syn::visit::visit_lit fn'>visit_lit</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit_bool.html" title='syn::visit::visit_lit_bool fn'>visit_lit_bool</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit_byte.html" title='syn::visit::visit_lit_byte fn'>visit_lit_byte</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit_byte_str.html" title='syn::visit::visit_lit_byte_str fn'>visit_lit_byte_str</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit_char.html" title='syn::visit::visit_lit_char fn'>visit_lit_char</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit_float.html" title='syn::visit::visit_lit_float fn'>visit_lit_float</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit_int.html" title='syn::visit::visit_lit_int fn'>visit_lit_int</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit_str.html" title='syn::visit::visit_lit_str fn'>visit_lit_str</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_lit_verbatim.html" title='syn::visit::visit_lit_verbatim fn'>visit_lit_verbatim</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_macro.html" title='syn::visit::visit_macro fn'>visit_macro</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_macro_delimiter.html" title='syn::visit::visit_macro_delimiter fn'>visit_macro_delimiter</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_member.html" title='syn::visit::visit_member fn'>visit_member</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_meta.html" title='syn::visit::visit_meta fn'>visit_meta</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_meta_list.html" title='syn::visit::visit_meta_list fn'>visit_meta_list</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_meta_name_value.html" title='syn::visit::visit_meta_name_value fn'>visit_meta_name_value</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_nested_meta.html" title='syn::visit::visit_nested_meta fn'>visit_nested_meta</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_parenthesized_generic_arguments.html" title='syn::visit::visit_parenthesized_generic_arguments fn'>visit_parenthesized_generic_arguments</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_path.html" title='syn::visit::visit_path fn'>visit_path</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_path_arguments.html" title='syn::visit::visit_path_arguments fn'>visit_path_arguments</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_path_segment.html" title='syn::visit::visit_path_segment fn'>visit_path_segment</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_predicate_eq.html" title='syn::visit::visit_predicate_eq fn'>visit_predicate_eq</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_predicate_lifetime.html" title='syn::visit::visit_predicate_lifetime fn'>visit_predicate_lifetime</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_predicate_type.html" title='syn::visit::visit_predicate_type fn'>visit_predicate_type</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_qself.html" title='syn::visit::visit_qself fn'>visit_qself</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_return_type.html" title='syn::visit::visit_return_type fn'>visit_return_type</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_span.html" title='syn::visit::visit_span fn'>visit_span</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_trait_bound.html" title='syn::visit::visit_trait_bound fn'>visit_trait_bound</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_trait_bound_modifier.html" title='syn::visit::visit_trait_bound_modifier fn'>visit_trait_bound_modifier</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type.html" title='syn::visit::visit_type fn'>visit_type</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_array.html" title='syn::visit::visit_type_array fn'>visit_type_array</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_bare_fn.html" title='syn::visit::visit_type_bare_fn fn'>visit_type_bare_fn</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_group.html" title='syn::visit::visit_type_group fn'>visit_type_group</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_impl_trait.html" title='syn::visit::visit_type_impl_trait fn'>visit_type_impl_trait</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_infer.html" title='syn::visit::visit_type_infer fn'>visit_type_infer</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_macro.html" title='syn::visit::visit_type_macro fn'>visit_type_macro</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_never.html" title='syn::visit::visit_type_never fn'>visit_type_never</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_param.html" title='syn::visit::visit_type_param fn'>visit_type_param</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_param_bound.html" title='syn::visit::visit_type_param_bound fn'>visit_type_param_bound</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_paren.html" title='syn::visit::visit_type_paren fn'>visit_type_paren</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_path.html" title='syn::visit::visit_type_path fn'>visit_type_path</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_ptr.html" title='syn::visit::visit_type_ptr fn'>visit_type_ptr</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_reference.html" title='syn::visit::visit_type_reference fn'>visit_type_reference</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_slice.html" title='syn::visit::visit_type_slice fn'>visit_type_slice</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_trait_object.html" title='syn::visit::visit_type_trait_object fn'>visit_type_trait_object</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_tuple.html" title='syn::visit::visit_type_tuple fn'>visit_type_tuple</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_type_verbatim.html" title='syn::visit::visit_type_verbatim fn'>visit_type_verbatim</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_un_op.html" title='syn::visit::visit_un_op fn'>visit_un_op</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_variant.html" title='syn::visit::visit_variant fn'>visit_variant</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_vis_crate.html" title='syn::visit::visit_vis_crate fn'>visit_vis_crate</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_vis_public.html" title='syn::visit::visit_vis_public fn'>visit_vis_public</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_vis_restricted.html" title='syn::visit::visit_vis_restricted fn'>visit_vis_restricted</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_visibility.html" title='syn::visit::visit_visibility fn'>visit_visibility</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_where_clause.html" title='syn::visit::visit_where_clause fn'>visit_where_clause</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="fn" href="fn.visit_where_predicate.html" title='syn::visit::visit_where_predicate fn'>visit_where_predicate</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "syn";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |