orium / rpds

Rust persistent data structures
Mozilla Public License 2.0
1.28k stars 58 forks source link

Allow the container of values to be either `Rc`, `Arc`, or owned. #36

Open orium opened 6 years ago

orium commented 6 years ago

Ref #22, #7.

carado commented 5 years ago

Hi ! In the interest of performance, it would also be nice to support servo_arc as an optional feature.

In the unlikely case you don't know about it, the hamt crate has a nice way of being generic over type-of-ownership, in a way that makes it easily extendable to custom ownership types such as servo_arc::Arc, or anything a user would implement; it only requires HamtRef: Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>> (see https://docs.rs/hamt/0.2.0/hamt/enum.Hamt.html).

orium commented 5 years ago

Hi @carado. Yes, supporting servo_arc seems like a good idea.

The strategy hamt is using to abstract from the pointer type works fine for its specific case, but becomes really unergonomic on other use cases (in particular when you want to use wrap different types on the shared pointer). Because of this I wrote archery to solve that, and I'm currently porting rpds to it.

One big limitation or archery is that it doesn't (easily) allow for users to create their own shared pointer types. I think this should be solvable, and I plan to explore that in the next version of archery.