diff options
| author | mo8it <mo8it@proton.me> | 2024-06-19 14:17:06 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-06-19 14:17:06 +0200 |
| commit | 532c9ebb30afa226590e68e87af11da42b598974 (patch) | |
| tree | dd397d1e19c5d8232c84726dde13265630bdb74d | |
| parent | 2a1bc5377177981fa253ae4cb234bce584ce1b62 (diff) | |
primitive_types5 solution
| -rw-r--r-- | exercises/04_primitive_types/primitive_types5.rs | 8 | ||||
| -rw-r--r-- | rustlings-macros/info.toml | 2 | ||||
| -rw-r--r-- | solutions/04_primitive_types/primitive_types5.rs | 9 |
3 files changed, 13 insertions, 6 deletions
diff --git a/exercises/04_primitive_types/primitive_types5.rs b/exercises/04_primitive_types/primitive_types5.rs index f2216a5..6e00ef5 100644 --- a/exercises/04_primitive_types/primitive_types5.rs +++ b/exercises/04_primitive_types/primitive_types5.rs @@ -1,8 +1,8 @@ -// Destructure the `cat` tuple so that the println will work. - fn main() { let cat = ("Furry McFurson", 3.5); - let /* your pattern here */ = cat; - println!("{} is {} years old.", name, age); + // TODO: Destructure the `cat` tuple in one statement so that the println works. + // let /* your pattern here */ = cat; + + println!("{name} is {age} years old"); } diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml index 313ba6f..e5f5877 100644 --- a/rustlings-macros/info.toml +++ b/rustlings-macros/info.toml @@ -286,7 +286,7 @@ Particularly the part about destructuring (second to last example in the section). You'll need to make a pattern to bind `name` and `age` to the appropriate parts -of the tuple. You can do it!!""" +of the tuple.""" [[exercises]] name = "primitive_types6" diff --git a/solutions/04_primitive_types/primitive_types5.rs b/solutions/04_primitive_types/primitive_types5.rs index 4e18198..46d7ae8 100644 --- a/solutions/04_primitive_types/primitive_types5.rs +++ b/solutions/04_primitive_types/primitive_types5.rs @@ -1 +1,8 @@ -// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 +fn main() { + let cat = ("Furry McFurson", 3.5); + + // Destructuring the tuple. + let (name, age) = cat; + + println!("{name} is {age} years old"); +} |
