Skip to content

Vec::drain() doesn't document any guarantees on order #135710

Closed
@EriKWDev

Description

@EriKWDev

Location

rustlib/src/rust/library/alloc/src/vec/mod.rs on pub fn drain<R>(&mut self, range: R) -> Drain<'_, T, A>, line 2603 in stable 1.84.0 (9fc6b4312 2025-01-07)

Summary

/// Removes the specified range from the vector in bulk, returning all
/// removed elements as an iterator. If the iterator is dropped before
/// being fully consumed, it drops the remaining removed elements.

"returning all removed elements as an iterator" remains ambiguous on the order of the elements.

I assume drain will continue to yield the items in the range order so could this be a documented guarantee?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library 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