From 3aa6c39c1ec2bb9a1eb5150c6ce42df0de8659c7 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sun, 3 Jan 2016 20:28:49 -0800 Subject: [PATCH] [rust] Day 5.0 refactoring --- rust/src/day_05.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rust/src/day_05.rs b/rust/src/day_05.rs index fa6be63..c98afc4 100644 --- a/rust/src/day_05.rs +++ b/rust/src/day_05.rs @@ -21,12 +21,7 @@ impl Day05 { } fn has_double_letters(string: &String) -> bool { - for win in string.as_bytes().windows(2) { - if win[0] == win[1] { - return true; - } - } - false + string.as_bytes().windows(2).any(|win| win[0] == win[1]) } fn has_no_substrings(string: &String) -> bool {