2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2014-08-02 02:38:10 +00:00
|
|
|
use std::mem;
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
static mut DROP_COUNT: usize = 0;
|
2014-08-02 02:38:10 +00:00
|
|
|
|
|
|
|
struct Fragment;
|
|
|
|
|
|
|
|
impl Drop for Fragment {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
unsafe {
|
|
|
|
DROP_COUNT += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
{
|
|
|
|
let mut fragments = vec![Fragment, Fragment, Fragment];
|
|
|
|
let _new_fragments: Vec<Fragment> = mem::replace(&mut fragments, vec![])
|
2014-09-15 03:27:36 +00:00
|
|
|
.into_iter()
|
2014-08-02 02:38:10 +00:00
|
|
|
.skip_while(|_fragment| {
|
|
|
|
true
|
|
|
|
}).collect();
|
|
|
|
}
|
|
|
|
unsafe {
|
|
|
|
assert_eq!(DROP_COUNT, 3);
|
|
|
|
}
|
|
|
|
}
|