✨ iterated fn + defer + retry
This commit is contained in:
parent
c010cc13e8
commit
18c663fcdb
11 changed files with 678 additions and 65 deletions
16
src/defer.rs
Normal file
16
src/defer.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
pub struct Defer {
|
||||
f: Box<dyn Fn()>,
|
||||
}
|
||||
|
||||
impl Defer {
|
||||
pub fn new<F: Fn() + 'static>(f: F) -> Self {
|
||||
Self { f: Box::new(f) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Defer {
|
||||
fn drop(&mut self) {
|
||||
log::debug!("Calling defer function");
|
||||
self.f.as_ref()();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue