finally-block

Crates.iofinally-block
lib.rsfinally-block
version0.2.0
sourcesrc
created_at2019-04-05 09:27:27.531066
updated_at2019-06-12 01:26:49.037384
descriptionFinal 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
repositoryhttp://github.com/CodeChain-io/rust-finally-block
max_upload_size
id125940
size5,865
codechain (github:codechain-io:codechain)

documentation

README

finally-block Build Status License: MIT

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()?;
    }
}
Commit count: 0

cargo fmt