Skip to content

Commit

Permalink
[lab 1] fix rust example
Browse files Browse the repository at this point in the history
  • Loading branch information
chiakicage committed Mar 23, 2024
1 parent 5cc6ca9 commit 5488b22
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ int main(){
在打印语法树时, 我们可以使用 match 语法来实现:
```rust
fn print_stmt(stmt: &Stmt) {
match stmt {
Stmt::Expr(expr) => print_expr(expr),
Stmt::IfStmt(if_stmt) => print_if_stmt(if_stmt),
Stmt::WhileStmt(while_stmt) => print_while_stmt(while_stmt),
Stmt::ReturnStmt(return_stmt) => print_return_stmt(return_stmt),
fn print_node(node: &Node) {
match node {
Node::Expr(expr) => print_expr(expr),
Node::IfStmt(if_stmt) => print_if_stmt(if_stmt),
Node::WhileStmt(while_stmt) => print_while_stmt(while_stmt),
Node::ReturnStmt(return_stmt) => print_return_stmt(return_stmt),
}
}
```
Expand Down

0 comments on commit 5488b22

Please sign in to comment.