We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 431d20e + 78cd734 commit a296933Copy full SHA for a296933
src/expressions/underscore-expr.md
@@ -10,10 +10,25 @@ side of an assignment.
10
11
Note that this is distinct from the [wildcard pattern](../patterns.md#wildcard-pattern).
12
13
-An example of an `_` expression:
+Examples of `_` expressions:
14
15
```rust
16
let p = (1, 2);
17
let mut a = 0;
18
(_, a) = p;
19
+
20
+struct Position {
21
+ x: u32,
22
+ y: u32,
23
+}
24
25
+Position { x: a, y: _ } = Position{ x: 2, y: 3 };
26
27
+// unused result, assignment to `_` used to declare intent and remove a warning
28
+_ = 2 + 2;
29
+// triggers unused_must_use warning
30
+// 2 + 2;
31
32
+// equivalent technique using a wildcard pattern in a let-binding
33
+let _ = 2 + 2;
34
```
0 commit comments