Closed TennyZhuang closed 11 months ago
We discussed this in the libs-api meeting today. We're happy to add this, but with only a single retain
method which accepts &mut T
. The split between retain
and retain_mut
was to correct a mistake: retain
was stabilized early on with a &T
signature and changing it would have broken many crates.
Proposal
Problem statement
It would be convenient if LinkedList had retain/retain_mut methods just like many other collections. We can migrate between different collections easily.
Motivating examples or use cases
When implementing MVCC transactions in database, it's very common to store the active transactions as a list. They'll be garbage collected by a monotonic version.
In fact, there are similar use cases like other collections.
Solution sketch
Alternatives
Links and related work
Vec::retain
Vec::retain_mut