INNER CODE UNIT · Rust
drop_notifier_calls_notify_on_drop
pamburus/hl · crates/lifecycle/src/lib.rs:82
fn drop_notifier_calls_notify_on_drop() {
let called = Arc::new(Mutex::new(false));
let called_clone = Arc::clone(&called);
{
let _notifier = DropNotifier::new(42, move || {
*called_clone.lock().unwrap() = true;
});
}
assert!(*called.lock().unwrap());
}
#[test]
fn drop_notifier_drops_inner_before_notify() {
let order = Arc::new(Mutex::new(Vec::new()));
let order_clone = Arc::clone(&order);