From: Greg Burri Date: Mon, 5 Dec 2022 11:21:00 +0000 (+0100) Subject: Simplify 'day05::get_top_as_string' X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=d9590b01179e15b0e7cabf5635caf44139524b1e;p=advent_of_code_2022.git Simplify 'day05::get_top_as_string' --- diff --git a/src/day05.rs b/src/day05.rs index 3a0f1bc..5e9daff 100644 --- a/src/day05.rs +++ b/src/day05.rs @@ -64,13 +64,7 @@ pub fn apply_moves_by_crate_mover_9001(stacks: &mut Stacks, moves: &[Move]) { } pub fn get_top_as_string(stacks: &Stacks) -> String { - let mut result = String::new(); - for stack in stacks { - if let Some(c) = stack.back() { - result.push(*c); - } - } - result + stacks.iter().map_while(VecDeque::back).collect() } #[cfg(test)]