From 48db1dde39987aa3734d9aff7f7ab1c159b7636c Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Fri, 30 Nov 2018 14:13:58 +0100 Subject: [PATCH] Simplify the "find" operation. --- 2016/src/day21.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/2016/src/day21.rs b/2016/src/day21.rs index aedbb32..570a649 100644 --- a/2016/src/day21.rs +++ b/2016/src/day21.rs @@ -1,5 +1,4 @@ use common; -use itertools::Itertools; use std::io::prelude::*; use std::io::BufReader; @@ -36,10 +35,7 @@ impl Day21 { fn find(&self, search: &str) -> usize { let c = search.chars().next().unwrap(); - match self.password.iter().find_position(|&&x| x == c) { - Some((pos, _)) => pos, - _ => panic!("Char not in password: {}", c) - } + self.password.iter().position(|&x| x == c).unwrap() } fn reverse_range(&mut self, pos_1: usize, pos_2: usize)