From a3f3b39123c79929b9af3f7b313e6b65f4feddb6 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 27 May 2019 13:13:17 -0300 Subject: [PATCH] if let is cuter --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index ce0fa32..9ed1bee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,9 +45,10 @@ fn main() { .take(2) .map(|record| { dump_record(&record); record }) .fold(None, {|first, current| { - match first { - Some(x) => Some(x), - None => Some(current.id) + if let Some(_) = first { + first + } else { + Some(current.id) } }}); log::debug!("First favourite: {:?}", most_recent_favourite);