Skip to content
This repository was archived by the owner on Sep 13, 2021. It is now read-only.

Latest commit

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

PinTree

HashMap/Set<Pin<Arc<T>>> based fully safety tree collection

Examples

letmut pt = PinTree::<i32>::new();let a = &pt.node(1);let b = &pt.node(2);let c = &pt.node(3);
pt.set_parent(b, a);
pt.set_parent(c, a);// a// ↙ ↘// b cassert_eq!(pt.is_parent(b, a),true);assert_eq!(pt.is_child(a, c),true);
// Circular references are safe
pt.set_parent(b, a);
pt.set_parent(a, c);
pt.set_parent(c, b);// a// ↙ ↖// b → c
pt.set_parent(a, a);// a ⟲
letmut pt = PinTree::<Mutex<i32>>::new();let a = pt.node(Mutex::new(1));letmut x = a.lock().unwrap();assert_eq!(*x,1);*x = 2;assert_eq!(*x,2);

Releases

Packages

Used by

Contributors

Languages