Module syn::fold

source ·
Expand description

Syntax tree traversal to transform the nodes of an owned syntax tree.

Each method of the Fold trait is a hook that can be overridden to customize the behavior when transforming 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.

pub trait Fold {
    /* ... */

    fn fold_expr_binary(&mut self, node: ExprBinary) -> ExprBinary {
        ExprBinary {
            attrs: node.attrs
                       .into_iter()
                       .map(|attr| self.fold_attribute(attr))
                       .collect(),
            left: Box::new(self.fold_expr(*node.left)),
            op: self.fold_bin_op(node.op),
            right: Box::new(self.fold_expr(*node.right)),
        }
    }

    /* ... */
}

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

Traits

Syntax tree traversal to transform the nodes of an owned syntax tree.

Functions