File tree 2 files changed +13
-8
lines changed
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,6 @@ fn foo(x: Empty) {
62
62
However, this won't:
63
63
64
64
```compile_fail
65
- enum Empty {}
66
-
67
65
fn foo(x: Option<String>) {
68
66
match x {
69
67
// empty
@@ -191,7 +189,7 @@ inner `String` to be moved into a variable called `s`.
191
189
let x = Some("s".to_string());
192
190
193
191
match x {
194
- op_string @ Some(s) => {},
192
+ op_string @ Some(s) => {}, // error: cannot bind by-move with sub-bindings
195
193
None => {},
196
194
}
197
195
```
@@ -288,7 +286,8 @@ struct X { x: (), }
288
286
289
287
let x = Some((X { x: () }, X { x: () }));
290
288
match x {
291
- Some((y, ref z)) => {},
289
+ Some((y, ref z)) => {}, // error: cannot bind by-move and by-ref in the
290
+ // same pattern
292
291
None => panic!()
293
292
}
294
293
```
@@ -574,6 +573,12 @@ be a compile-time constant. Erroneous code example:
574
573
let x = [0i32; len]; // error: expected constant integer for repeat count,
575
574
// found variable
576
575
```
576
+
577
+ Working example:
578
+
579
+ ```
580
+ let x = [0i32; 10];
581
+ ```
577
582
"## ,
578
583
579
584
}
Original file line number Diff line number Diff line change @@ -45,8 +45,8 @@ Matching with the wrong number of fields has no sensible interpretation:
45
45
46
46
```compile_fail
47
47
enum Fruit {
48
- Apple(String, String),
49
- Pear(u32),
48
+ Fruit:: Apple(String, String),
49
+ Fruit:: Pear(u32),
50
50
}
51
51
52
52
let x = Fruit::Apple(String::new(), String::new());
@@ -77,8 +77,8 @@ enum Number {
77
77
78
78
// Assuming x is a Number we can pattern match on its contents.
79
79
match x {
80
- Zero(inside) => {},
81
- One(inside) => {},
80
+ Number:: Zero(inside) => {},
81
+ Number:: One(inside) => {},
82
82
}
83
83
```
84
84
You can’t perform that action at this time.
0 commit comments