mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
Add tuple exercise from @ruipserra! 😻
This commit is contained in:
parent
98cde6f9b1
commit
bbe1dc5937
44
primitive_types/primitive_types5.rs
Normal file
44
primitive_types/primitive_types5.rs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// Destructure the `cat` tuple so that the println will work.
|
||||||
|
// Scroll down for hints!
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let cat = ("Furry McFurson", 3.5);
|
||||||
|
let /* your pattern here */ = cat;
|
||||||
|
|
||||||
|
println!("{} is {} years old.", name, age);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Take a look at the Primitive Types -> Tuples section of the book:
|
||||||
|
// http://doc.rust-lang.org/stable/book/primitive-types.html#tuples
|
||||||
|
// Particularly the part about "destructuring lets". You'll need to
|
||||||
|
// make a pattern to bind `name` and `age` to the appropriate parts
|
||||||
|
// of the tuple. You can do it!!
|
Loading…
Reference in a new issue