]> git.lizzy.rs Git - rust.git/commitdiff
Add OnDrop
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Thu, 15 Mar 2018 09:38:12 +0000 (10:38 +0100)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Sat, 17 Mar 2018 22:01:55 +0000 (23:01 +0100)
src/librustc_data_structures/lib.rs

index 81246aea1b56e26541ab98414fbc92984927f1ac..bf0b3726bb301a46f13a6d07b993ea2084ed154d 100644 (file)
 pub mod sync;
 pub mod owning_ref;
 
+pub struct OnDrop<F: Fn()>(pub F);
+
+impl<F: Fn()> Drop for OnDrop<F> {
+      fn drop(&mut self) {
+            (self.0)();
+      }
+}
+
 // See comments in src/librustc/lib.rs
 #[doc(hidden)]
 pub fn __noop_fix_for_27438() {}