rust: types: introduce `ScopeGuard`
authorWedson Almeida Filho <wedsonaf@gmail.com>
Mon, 30 Jan 2023 06:44:00 +0000 (03:44 -0300)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 31 Jan 2023 23:14:01 +0000 (00:14 +0100)
commit4d4692a2ff836487c17960a6211a4cce7094f09c
tree1e4d1feb8d391448da47343301d8f8a83674cacf
parentdec1df547d812a5ced4de29e7eadcfa0484bec1e
rust: types: introduce `ScopeGuard`

This allows us to run some code when the guard is dropped (e.g.,
implicitly when it goes out of scope). We can also prevent the
guard from running by calling its `dismiss()` method.

Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com>
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/types.rs