Amanieu / intrusive-rs

Intrusive collections for Rust
Apache License 2.0
412 stars 48 forks source link

Singly-linked list with push_back? #32

Open g2p opened 5 years ago

g2p commented 5 years ago

I would find it convenient (for implementing a custom LRU, with some fancy features but no way to remove arbitrary elements) to have a singly-linked list (with pointers going from the oldest LRU element to the newest), that also allows adding to the end of the list. The APIs for getting CursorMut prevent this by forbidding keeping a mutable cursor to the end while accessing the list. Having a private CursorMut pointing to the end would allow providing a safe push_back API.

Would you be amenable to this idea? Should I send a pull request?

Amanieu commented 5 years ago

Sure! I would be happy to accept a pull request for this.

What do you have in mind for this? A separate SinglyLinkedListTail type?

g2p commented 5 years ago

I agree, a separate list type would work best. I've given it more thought, and I need to customize more things for my LRU before I can extract a generally useful solution.