From 8aabdde4bf29b6a6d1bd1da327d6da5ce0f69464 Mon Sep 17 00:00:00 2001 From: Totoro Date: Thu, 17 Sep 2026 11:18:37 +0800 Subject: [PATCH] Add Rust example for tuple destructuring Added example code for tuple destructuring in Rust. --- solutions/ownership/ownership.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/solutions/ownership/ownership.md b/solutions/ownership/ownership.md index c1429856c..78d196ab8 100644 --- a/solutions/ownership/ownership.md +++ b/solutions/ownership/ownership.md @@ -188,3 +188,13 @@ fn main() { println!("{:?}, {:?}, {:?}", s1, s2, t); // -> "hello", "world", ("hello", "world") } ``` +```rust +fn main() { + let t = (String::from("hello"), String::from("world")); + + // fill the blanks + let (s1, s2) = &t; + + println!("{:?}, {:?}, {:?}", s1, s2, t); // -> "hello", "world", ("hello", "world") +} +```