Rust crate for a convenient RAII scope guard.
Please read the API documentation here
__
__ http://bluss.github.io/scopeguard
|buildstatus| |crates|_
.. |buildstatus| image:: https://travis-ci.org/bluss/scopeguard.svg .. _buildstatus: https://travis-ci.org/bluss/scopeguard
.. |crates| image:: http://meritbadge.herokuapp.com/scopeguard .. _crates: https://crates.io/crates/scopeguard
::
#[macro_use(defer)] extern crate scopeguard;
use scopeguard::guard;
fn f() {
defer!(println!("Called at return or panic"));
panic!();
}
fn g() {
let f = File::create("newfile.txt").unwrap();
let mut file = guard(f, |f| {
// write file at return or panic
f.sync_all();
});
file.write("testme\n");
}
0.2.0
no_std
unconditionally0.1.2
defer!()