mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-29 01:29:00 +00:00
@@ -1,2 +1,21 @@
|
||||
pub mod error;
|
||||
pub mod globals;
|
||||
|
||||
/// Defers evaluation of a block of code until the end of the scope.
|
||||
#[macro_export] macro_rules! defer {
|
||||
($($body:tt)*) => {
|
||||
let _guard = {
|
||||
pub struct Guard<F: FnOnce()>(Option<F>);
|
||||
|
||||
impl<F: FnOnce()> Drop for Guard<F> {
|
||||
fn drop(&mut self) {
|
||||
(self.0).take().map(|f| f());
|
||||
}
|
||||
}
|
||||
|
||||
Guard(Some(|| {
|
||||
let _ = { $($body)* };
|
||||
}))
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user