Closed
Description
use std::mem;
struct Fragment {
dummy: int
}
impl Fragment {
fn new(d: int) -> Fragment {
Fragment {
dummy: d,
}
}
}
impl Drop for Fragment {
fn drop(&mut self) {
println!("drop {}", self.dummy);
}
}
fn main() {
let mut fragments = vec!();
fragments.push(Fragment::new(1));
fragments.push(Fragment::new(2));
let new_fragments: Vec<Fragment> = mem::replace(&mut fragments, vec![])
.move_iter()
.skip_while(|fragment| {
true
}).collect();
}
Produces the following output:
drop 1
drop 2
drop 2
Metadata
Metadata
Assignees
Labels
No labels