diff --git a/src/flow_control/match/destructuring/destructure_structures.md b/src/flow_control/match/destructuring/destructure_structures.md index 252104fefa..96b24368f5 100644 --- a/src/flow_control/match/destructuring/destructure_structures.md +++ b/src/flow_control/match/destructuring/destructure_structures.md @@ -30,6 +30,15 @@ fn main() { // You do not need a match block to destructure structs: let Foo { x : x0, y: y0 } = faa; println!("Outside: x0 = {x0:?}, y0 = {y0}"); + + // Destructuring works with nested structs as well: + struct Bar { + foo: Foo, + } + + let bar = Bar { foo: faa }; + let Bar { foo: Foo { x: nested_x, y: nested_y } } = bar; + println!("Nested: nested_x = {nested_x:?}, nested_y = {nested_y:?}"); } ```