Skip to main content

guard

Function guard 

Source
pub fn guard<T, F>(resource: T, cleanup: F) -> Guard<T, F>
where F: FnOnce(T),
Expand description

Create a simple RAII guard with cleanup function

This is the most basic guard pattern - useful for any resource that needs cleanup

ยงExample

use foundation_utils::guard;

let _guard = guard("my_resource", |r| {
    println!("Cleaning up: {}", r);
});
// Cleanup happens automatically when guard drops