mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Format
This commit is contained in:
@@ -1566,10 +1566,13 @@ impl<T, F> Drop for DrainFilter<'_, T, F>
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
struct DropGuard<'r, 'a, T, F>(&'r mut DrainFilter<'a, T, F>)
|
||||
where F: FnMut(&mut T) -> bool;
|
||||
where
|
||||
F: FnMut(&mut T) -> bool;
|
||||
|
||||
impl<'r, 'a, T, F> Drop for DropGuard<'r, 'a, T, F>
|
||||
where F: FnMut(&mut T) -> bool {
|
||||
where
|
||||
F: FnMut(&mut T) -> bool,
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
self.0.for_each(drop);
|
||||
}
|
||||
|
||||
@@ -590,13 +590,12 @@ fn drop(&mut self) {
|
||||
q.push_front(D(1));
|
||||
q.push_front(D(0));
|
||||
|
||||
catch_unwind(AssertUnwindSafe(|| drop(q.drain_filter(|item| if item.0 >= 2 {
|
||||
panic!()
|
||||
} else {
|
||||
true
|
||||
})))).ok();
|
||||
catch_unwind(AssertUnwindSafe(|| {
|
||||
drop(q.drain_filter(|item| if item.0 >= 2 { panic!() } else { true }))
|
||||
}))
|
||||
.ok();
|
||||
|
||||
assert_eq!(unsafe { DROPS }, 2); // 0 and 1
|
||||
assert_eq!(unsafe { DROPS }, 2); // 0 and 1
|
||||
assert_eq!(q.len(), 6);
|
||||
}
|
||||
|
||||
|
||||
@@ -783,11 +783,7 @@ fn drop(&mut self) {
|
||||
}
|
||||
}
|
||||
|
||||
let v = vec![
|
||||
D(false),
|
||||
D(true),
|
||||
D(false),
|
||||
];
|
||||
let v = vec![D(false), D(true), D(false)];
|
||||
|
||||
catch_unwind(move || drop(v.into_iter())).ok();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
use std::collections::{vec_deque::Drain, VecDeque};
|
||||
use std::fmt::Debug;
|
||||
use std::mem::size_of;
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind};
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
use std::{isize, usize};
|
||||
|
||||
use crate::hash;
|
||||
@@ -1637,7 +1637,8 @@ fn drop(&mut self) {
|
||||
|
||||
catch_unwind(AssertUnwindSafe(|| {
|
||||
v.drain(1..=4);
|
||||
})).ok();
|
||||
}))
|
||||
.ok();
|
||||
|
||||
assert_eq!(unsafe { DROPS }, 4);
|
||||
assert_eq!(v.len(), 3);
|
||||
|
||||
Reference in New Issue
Block a user