#defer #scope #guard #drop #macro

deferrer

defer! macro for deferring functions

4 releases

0.1.4 Jan 20, 2021
0.1.3 Jan 6, 2021
0.1.2 Jan 6, 2021
0.1.1 Jan 6, 2021

#2332 in Rust patterns

GPL-2.0 license

3KB

Deferrer

defer! macro for deferring functions.

Example

use deferrer::*;
use std::cell::RefCell;

let mut s = RefCell::new(String::from("Hello"));
{
	defer!( || s.borrow_mut().push_str(" world!") );
 	assert_eq!(*s.borrow(), "Hello");
}
assert_eq!(*s.borrow(), "Hello world!");

No runtime deps