projects
/
advent_of_code_2022.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
23b0e5c
)
Simplify 'day05::get_top_as_string'
author
Greg Burri
<greg.burri@gmail.com>
Mon, 5 Dec 2022 11:21:00 +0000
(12:21 +0100)
committer
Greg Burri
<greg.burri@gmail.com>
Mon, 5 Dec 2022 11:21:00 +0000
(12:21 +0100)
src/day05.rs
patch
|
blob
|
history
diff --git
a/src/day05.rs
b/src/day05.rs
index
3a0f1bc
..
5e9daff
100644
(file)
--- 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)]