@@ -33,30 +33,28 @@ pub trait AstNode: std::fmt::Debug {
33
33
///
34
34
/// This is supposed visit child nodes in the correct order.
35
35
///
36
- /// Visitor implementations are supposed to call this method for traversing.
36
+ /// Visitor implementations call this method for traversing.
37
37
fn visit_children ( & self , _ast_visitor : & mut impl AstVisitor ) { }
38
38
39
39
/// Returns the lexer (source) location of the node.
40
40
fn location ( & self ) -> Location ;
41
41
}
42
42
43
- /// This trait allows implementing custom AST visitor logic for each node type,
44
- /// without needing to worry about how the nodes must be traversed.
43
+ /// This trait allows implementing custom AST visitor logic for each node type.
45
44
///
46
- /// The only thing the visitor needs to ensure is to call the nodes
47
- /// [AstNode::visit_children] method (in any trait method).
48
- /// This simplifies the implementation fo AST visitors a lot (see below example).
45
+ /// The visitor can call the nodes [AstNode::visit_children] method (from any
46
+ /// other trait method). This simplifies the implementation of AST visitors.
49
47
///
50
- /// Default implementations which do nothing except for visiting children
51
- /// are provided for each node type.
48
+ /// Default implementations which do nothing except accepting the visitor via the
49
+ /// [AstVisitor::visit] method are provided for each node type.
52
50
///
53
- /// The [AstVisitor::visit] method is the generic visitor method,
54
- /// which is seen by all nodes.
51
+ /// The [AstVisitor::visit] method is the generic visitor method, seen by all
52
+ /// nodes.
55
53
///
56
- /// Visited nodes are given read only access (non-mutable refernces) on purpose,
57
- /// as it's a compiler design best practice to not mutate the AST after parsing.
58
- /// Instead, mutable access to the [AstVisitor] instance itself is,
59
- /// provided, allowing to build a new representation instead if needed.
54
+ /// Visited nodes are given read only access (non-mutable references); it's a
55
+ /// compiler design practice to not mutate the AST after parsing.
56
+ /// Instead, mutable access to the [AstVisitor] instance itself is provided ,
57
+ /// allowing to build a new representation if needed.
60
58
///
61
59
/// # Example
62
60
///
0 commit comments