kseo / rust-finally-block

Final block that is executed at the last

Home Page:https://crates.io/crates/finally-block

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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()?;
    }
}

About

Final block that is executed at the last

https://crates.io/crates/finally-block

License:MIT License


Languages

Language:Rust 100.0%