From d9590b01179e15b0e7cabf5635caf44139524b1e Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Mon, 5 Dec 2022 12:21:00 +0100 Subject: [PATCH] Simplify 'day05::get_top_as_string' --- src/day05.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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)] -- 2.45.2