Crates.io | finally-block |
lib.rs | finally-block |
version | 0.2.0 |
source | src |
created_at | 2019-04-05 09:27:27.531066 |
updated_at | 2019-06-12 01:26:49.037384 |
description | Final block is a block that is executed when it dropped. It helps a user to write the deferred statements that should be executed even some statements return early. |
homepage | |
repository | http://github.com/CodeChain-io/rust-finally-block |
max_upload_size | |
id | 125940 |
size | 5,865 |
Finally block is a block that is executed when it's dropped. It helps a user write the deferred statements that should be executed, even when some statements return early.
function f(flag: &AtomicBool) -> Option<()> {
if some_condition {
let _f = finally(|| {
flag.store(true, Ordering::SeqCst);
});
some_function(flag)?;
} else {
another_function()?;
}
}