Skip to content

Commit 37f9c7f

Browse files
committed
Add OnDrop
1 parent 8e5eb02 commit 37f9c7f

File tree

1 file changed

+8
-0
lines changed
  • src/librustc_data_structures

1 file changed

+8
-0
lines changed

src/librustc_data_structures/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ pub mod flock;
7676
pub mod sync;
7777
pub mod owning_ref;
7878

79+
pub struct OnDrop<F: Fn()>(pub F);
80+
81+
impl<F: Fn()> Drop for OnDrop<F> {
82+
fn drop(&mut self) {
83+
(self.0)();
84+
}
85+
}
86+
7987
// See comments in src/librustc/lib.rs
8088
#[doc(hidden)]
8189
pub fn __noop_fix_for_27438() {}

0 commit comments

Comments
 (0)