Skip to content

Commit 6ac1fb4

Browse files
committed
use split_off instead of drain
1 parent edd5e1f commit 6ac1fb4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

day_05/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn run_instructions_with_single_pick_up(
102102

103103
// Move items one by one. Once could re-use loop-less solution from
104104
// [`run_instructions_with_multi_pick_up`], by just reversing the order
105-
// of items returned by [`std::vec::Vec::drain`], but this way the
105+
// of items returned by [`std::vec::Vec::split_off`], but this way the
106106
// intention is much clearer
107107
for _ in 0..num {
108108
let v = stacks[from]
@@ -130,7 +130,7 @@ fn run_instructions_with_multi_pick_up(
130130
.len()
131131
.checked_sub(num)
132132
.ok_or_else(|| anyhow!("stack {} has less than {} items left on it", from, num))?;
133-
let mut v = stacks[from].drain(idx_to_pick_up_from..).collect();
133+
let mut v = stacks[from].split_off(idx_to_pick_up_from);
134134
stacks[to].append(&mut v);
135135
}
136136

0 commit comments

Comments
 (0)