#block #raii #control #finally

finally-block

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

3 unstable releases

0.2.0 Jun 12, 2019
0.1.1 Apr 5, 2019
0.1.0 Apr 5, 2019

#6 in #raii

Download history 38/week @ 2024-02-19 18/week @ 2024-02-26 7/week @ 2024-03-04 37/week @ 2024-03-11 5/week @ 2024-03-18 7/week @ 2024-03-25 77/week @ 2024-04-01

127 downloads per month
Used in redmine-api

MIT license

4KB

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

No runtime deps