feat: Add option3 exercise
This commit is contained in:
parent
528e45ea4c
commit
9b3e700edf
20
exercises/option/option3.rs
Normal file
20
exercises/option/option3.rs
Normal 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;
|
||||
}
|
10
info.toml
10
info.toml
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue