- I have this code:
pub struct Foo {}
pub fn good(dst: &mut Vec<Foo>, src: &mut Vec<Foo>) {
while src.len() != 0 {
dst.push(src.pop().unwrap())
}
}
pub fn bad(dst: &mut Vec<Foo>, src: &mut Vec<Foo>) {
for x in src.into_iter().rev() {
src.push(x)
}
}
-
I would like to write the same function via iterator instead of pop.
-
How can I do this? The requirements are:
3a. src ends up empty
3b. elements of src are reversed + appended to dst