From 9b3e700edf37fe2e5caaa0cd818174807dfe838b Mon Sep 17 00:00:00 2001 From: Sateesh Basavaraju Date: Sat, 8 May 2021 15:22:27 +0530 Subject: [PATCH] feat: Add option3 exercise --- exercises/option/option3.rs | 20 ++++++++++++++++++++ info.toml | 10 ++++++++++ 2 files changed, 30 insertions(+) create mode 100644 exercises/option/option3.rs diff --git a/exercises/option/option3.rs b/exercises/option/option3.rs new file mode 100644 index 0000000..77dd4f0 --- /dev/null +++ b/exercises/option/option3.rs @@ -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 = 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; +} diff --git a/info.toml b/info.toml index 9f35d50..7171d86 100644 --- a/info.toml +++ b/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"