Skip to content

drain() doc of vector is unclear #73844

Closed

Description

I wanted to move out a number of front element from a vector, like my_vec.drain(..x) but I wonder if this is the right way to do this cause doc is unclear, note 1 and note 2 say the opposite each other:

Creates a draining iterator that removes the specified range in the vector and yields the removed items.

Note 1: The element range is removed even if the iterator is only partially consumed or not consumed at all.

Note 2: It is unspecified how many elements are removed from the vector if the Drain value is leaked.

https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain

This issue has been assigned to @poliorcetics via this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-collectionsArea: `std::collection`A-docsArea: documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions