diff options
Diffstat (limited to 'crates/ra_syntax/src/lib.rs')
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 4c4e0580a..2bced1867 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -186,8 +186,8 @@ fn api_walkthrough() { | |||
186 | // Let's fetch the `foo` function. | 186 | // Let's fetch the `foo` function. |
187 | let mut func = None; | 187 | let mut func = None; |
188 | for item in file.items() { | 188 | for item in file.items() { |
189 | match item.kind() { | 189 | match item { |
190 | ast::ModuleItemKind::FnDef(f) => func = Some(f), | 190 | ast::ModuleItem::FnDef(f) => func = Some(f), |
191 | _ => unreachable!(), | 191 | _ => unreachable!(), |
192 | } | 192 | } |
193 | } | 193 | } |
@@ -206,12 +206,12 @@ fn api_walkthrough() { | |||
206 | let block: ast::Block = func.body().unwrap(); | 206 | let block: ast::Block = func.body().unwrap(); |
207 | let expr: ast::Expr = block.expr().unwrap(); | 207 | let expr: ast::Expr = block.expr().unwrap(); |
208 | 208 | ||
209 | // "Enum"-like nodes are represented using the "kind" pattern. It allows us | 209 | // Enums are used to group related ast nodes together, and can be used for |
210 | // to match exhaustively against all flavors of nodes, while maintaining | 210 | // matching. However, because there are no public fields, it's possible to |
211 | // internal representation flexibility. The drawback is that one can't write | 211 | // match only the top level enum: that is the price we pay for increased API |
212 | // nested matches as one pattern. | 212 | // flexibility |
213 | let bin_expr: ast::BinExpr = match expr.kind() { | 213 | let bin_expr: &ast::BinExpr = match &expr { |
214 | ast::ExprKind::BinExpr(e) => e, | 214 | ast::Expr::BinExpr(e) => e, |
215 | _ => unreachable!(), | 215 | _ => unreachable!(), |
216 | }; | 216 | }; |
217 | 217 | ||