Skip to content

Want to extend clear_with_drain to other types of containers #10572

Closed
@bluthej

Description

@bluthej

I implemented clear_with_drain for Vec, and then I had a look at #9059 and saw that manual_retain applies to a bunch of containers (BTW I admire your work on that lint @kyoto7250 👏).

So I'm thinking clear_with_drain should probably be extended in a similar fashion to apply to the collections in std that have both a clear and a drain method, i.e.:

What do you think?

Also note that the documentations for Vec, VecDeque and String explicitly mention that drain with a full range will clear the container, "like clear() does". Does this change anything regarding the category proposed originally in #9339? Style was suggested, but that would mean the examples in the standard library would get warnings 😅. Maybe Pedantic is more suitable?

@rustbot label +C-enhancement

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions