feat: Add option3 exercise

This commit is contained in:
Sateesh Basavaraju 2021-05-08 15:22:27 +05:30
parent 528e45ea4c
commit 9b3e700edf
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,20 @@
// option2.rs
// Make me compile! Execute `rustlings hint option3` for hints
// I AM NOT DONE
struct Point {
x: i32,
y: i32,
}
fn main() {
let y: Option<Point> = Some(Point { x: 100, y: 200 });
match y {
Some(p) => println!("Co-ordinates are{},{} ", p.x, p.y),
_ => println!("no match"),
}
// Fix without deleting this line.
y;
}

View file

@ -585,6 +585,16 @@ For example: Some(Some(variable)) = variable2
Also see Option::flatten
"""
[[exercises]]
name = "option3"
path = "exercises/option/option3.rs"
mode = "compile"
hint = """
The compiler says a partial move happened in the `match`
statement. How can this be avoided ? The compiler shows the correction
needed. After making the correction as suggested by the compiler, do
read: https://doc.rust-lang.org/std/keyword.ref.html"""
[[exercises]]
name = "result1"
path = "exercises/error_handling/result1.rs"