refslots 0.1.0

Reference-counted handles to slots in a slotmap
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! # recorder
//!
//! Detect leaked handles when the registry is dropped. Enabled by the recorder which tracks live
//! handles for each slot. Run with `cargo run --example=recorder --features=recorder`.

use parking_lot::RwLock;
use refslots::{Handle, Registry};
use slotmap::DefaultKey;
use std::sync::Arc;

fn main() {
    let registry = Arc::new(RwLock::new(Registry::<DefaultKey>::default()));
    let handle = Handle::insert(&registry, ());
    let _clone = handle.clone();

    // Drop the registry before dropping the handles.
    drop(registry);
}