Amanieu / intrusive-rs

Intrusive collections for Rust
Apache License 2.0
400 stars 47 forks source link

Would it be possible to be generic over the reference type? #27

Open llogiq opened 5 years ago

llogiq commented 5 years ago

I'm looking into getting more real-world tests for compact_arena, and intrusive collections should be a good fit. However, intrusive-rs uses *const pointers internally.

Would you accept a PR that makes the structures generic over the pointer type and perhaps add a scope type so that we could use compact_arena with this?

Amanieu commented 5 years ago

Sure, I'd be happy to accept a PR!

This is something that I've actually wanted to do for a long time, but I've been busy with other stuff and have never actually gotten around to it.

However keep in mind this isn't as simple as it seems design-wise. You'll probably want to put the index<->pointer conversion in the Adapter trait somehow so that you only need one reference to the arena per collection, rather than per node.

llogiq commented 5 years ago

Perfect!

llogiq commented 5 years ago

I only see the need for an index → pointer conversion, not vice versa. Do we need both to_ptr and to_mut_ptr?

llogiq commented 5 years ago

Gee, that's a gnarly macro.