Add and use OnDrop::disable
This commit is contained in:
parent
77259af56a
commit
090b8341bc
@ -456,5 +456,5 @@ fn deadlock(tcx: TyCtxt<'_, '_, '_>, registry: &rayon_core::Registry) {
|
|||||||
waiter.notify(tcx, registry);
|
waiter.notify(tcx, registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
mem::forget(on_panic);
|
on_panic.disable();
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,14 @@ pub mod sorted_map;
|
|||||||
|
|
||||||
pub struct OnDrop<F: Fn()>(pub F);
|
pub struct OnDrop<F: Fn()>(pub F);
|
||||||
|
|
||||||
|
impl<F: Fn()> OnDrop<F> {
|
||||||
|
/// Forgets the function which prevents it from running.
|
||||||
|
/// Ensure that the function owns no memory, otherwise it will be leaked.
|
||||||
|
pub fn disable(self) {
|
||||||
|
std::mem::forget(self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<F: Fn()> Drop for OnDrop<F> {
|
impl<F: Fn()> Drop for OnDrop<F> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
(self.0)();
|
(self.0)();
|
||||||
|
Loading…
Reference in New Issue
Block a user