Browse code

if let is cuter

Julio Biason authored on 27/05/2019 09:13:17
Showing 1 changed files

... ...
@@ -45,9 +45,10 @@ fn main() {
45 45
         .take(2)
46 46
         .map(|record| { dump_record(&record); record })
47 47
         .fold(None, {|first, current| {
48
-            match first {
49
-                Some(x) => Some(x),
50
-                None => Some(current.id)
48
+            if let Some(_) = first {
49
+                first
50
+            } else {
51
+                Some(current.id)
51 52
             }
52 53
         }});
53 54
     log::debug!("First favourite: {:?}", most_recent_favourite);