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 70e0f0a + eef6545 commit 4c2b24fCopy full SHA for 4c2b24f
src/flow_control/match/destructuring/destructure_structures.md
@@ -30,6 +30,15 @@ fn main() {
30
// You do not need a match block to destructure structs:
31
let Foo { x : x0, y: y0 } = faa;
32
println!("Outside: x0 = {x0:?}, y0 = {y0}");
33
+
34
+ // Destructuring works with nested structs as well:
35
+ struct Bar {
36
+ foo: Foo,
37
+ }
38
39
+ let bar = Bar { foo: faa };
40
+ let Bar { foo: Foo { x: nested_x, y: nested_y } } = bar;
41
+ println!("Nested: nested_x = {nested_x:?}, nested_y = {nested_y:?}");
42
}
43
```
44
0 commit comments