https://github.com/codechain-io/rust-finally-block
Final block that is executed at the last
https://github.com/codechain-io/rust-finally-block
finally rust
Last synced: 4 months ago
JSON representation
Final block that is executed at the last
- Host: GitHub
- URL: https://github.com/codechain-io/rust-finally-block
- Owner: CodeChain-io
- License: mit
- Created: 2019-04-05T09:07:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-23T02:45:48.000Z (about 6 years ago)
- Last Synced: 2025-04-05T07:51:18.244Z (10 months ago)
- Topics: finally, rust
- Language: Rust
- Homepage: https://crates.io/crates/finally-block
- Size: 21.5 KB
- Stars: 4
- Watchers: 8
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# finally-block [](https://travis-ci.com/CodeChain-io/rust-finally-block) [](https://opensource.org/licenses/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.
```rust
function f(flag: &AtomicBool) -> Option<()> {
if some_condition {
let _f = finally(|| {
flag.store(true, Ordering::SeqCst);
});
some_function(flag)?;
} else {
another_function()?;
}
}
```