From 8bde1dbc728c5cc1a45b1ed85359f1b97fa1cdf6 Mon Sep 17 00:00:00 2001 From: Yufan Lou Date: Mon, 25 Mar 2019 02:54:32 -0400 Subject: [PATCH] Add exercise 10.2 (#24) --- src/part10.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/part10.rs b/src/part10.rs index 39270de..dc73d87 100644 --- a/src/part10.rs +++ b/src/part10.rs @@ -164,5 +164,13 @@ fn filter_vec_by_divisor(v: &Vec, divisor: i32) -> Vec { // those numbers that sit at odd positions? A function that checks whether a vector contains a // certain number? Whether all numbers are smaller than some threshold? Be creative! +// **Exercise 10.2**: We started the journey in Part 02 with `SomethingOrNothing`, and later +// learned about `Option` in Part 04. `Option` also has a `map` function. +// [Read its documentation here.](https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.map) +// Which functions in previous Parts can you rewrite to use `map` instead? +// (Hint: read the source code of `map`, and see if the pattern appears in your own code) +// (Bonus: [`test_invariant` in Part 05](part05.html#section-6) doesn't use `match`, +// but can you still find a way to rewrite it with `map`?) + //@ [index](main.html) | [previous](part09.html) | [raw source](workspace/src/part10.rs) | //@ [next](part11.html) -- 2.30.2