#scope-guard #defer #panic

scopeguard

A RAII scope guard that will run a given closure when it goes out of scope, even if the code between panics (assuming unwinding panic). Defines the macros defer! and defer_on_unwind!; the latter only runs if the scope is extited through unwinding on panic.

8 releases

0.3.3 Oct 13, 2017
0.3.2 Jan 21, 2017
0.3.1 Dec 11, 2016
0.2.0 Jun 23, 2016
0.1.0 Apr 30, 2015

#3 in Rust patterns

Download history 25673/week @ 2018-05-06 33276/week @ 2018-05-13 31921/week @ 2018-05-20 29708/week @ 2018-05-27 30787/week @ 2018-06-03 32481/week @ 2018-06-10 28805/week @ 2018-06-17 29844/week @ 2018-06-24 30549/week @ 2018-07-01 30768/week @ 2018-07-08 33756/week @ 2018-07-15 33747/week @ 2018-07-22 28048/week @ 2018-07-29

112,505 downloads per month

scopeguard

Rust crate for a convenient RAII scope guard that will run a given closure when it goes out of scope, even if the code between panics (assuming unwinding panic).

The defer! macro and guard are no_std compatible (require only core), but the on unwinding strategy requires linking to std.

Requires Rust 1.11.

Please read the API documentation here

build_status crates

How to use

Recent Changes

  • 0.3.3
    • Use #[inline] on a few more functions by @stjepang (#14)
    • Add examples to crate documentation
  • 0.3.2
    • Add crate categories
  • 0.3.1
    • Add defer_on_unwind!, Strategy trait
    • Rename GuardScopeGuard
    • Add ScopeGuard::with_strategy.
    • ScopeGuard now implements Debug.
    • Require Rust 1.11
  • 0.2.0
    • Require Rust 1.6
    • Use no_std unconditionally
    • No other changes
  • 0.1.2
    • Add macro defer!()
MIT/Apache-2.0 license
  • No runtime deps

Reverse deps