Skip to content

Vec::insert docs are wrong about panic condition #47065

Closed
@Arnavion

Description

@Arnavion

rust/src/liballoc/vec.rs

Lines 716 to 718 in f0e5c95

/// # Panics
///
/// Panics if `index` is out of bounds.

In fact, as the second example shows, index == len is allowed. The phrase "out of bounds" is used in the docs of other methods (remove and swap_remove) to mean 0 <= index < len so it should not be used to mean 0 <= index <= len here.

Suggest changing the wording to match Vec::split_off :

Panics if index > len.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions