-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Description
Firstly, I believe it would be sound for the function passed to retain
to take a mutable reference instead of an immutable one. There is no real reason to restrict this. Additionally, I've found it useful to return the removed array as an &mut [T]
- since all the elements are at the end anyway this is essentially free. In my case I only allow this when the elements are Copy
(as a hack around not being able to specify !Drop
), but it would be sound to allow Drop
types. The issue is that it would unconditionally leak, which would be solved by an additional type that derefences to &mut [T]
but that drops its elements on drop. It would have to take a lifetime parameter to disallow mutating the vector after returning the elements.
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.