Skip to content

Vec.resize(), Vec.resize_with() should be marked as panicking if the new capacity exceeds isize::MAX bytes #117437

Closed
@LikeLakers2

Description

@LikeLakers2

Location

In the documentation for the following functions:

I noted some trait impls where they might want to be added (such as the Extend trait impls on Vec), but I'm unsure if it makes sense for the "Panics" notes to be added to them.

Summary

These should be marked with the following:

# Panics

Panics if the new capacity exceeds `isize::MAX` bytes.

as they all, in one way or another, call Vec.reserve(), which itself will panic if the new capacity exceeds isize::MAX bytes.

Because other functions that call Vec.reserve() (such as Vec.push() or Vec::with_capacity()) are marked with this "Panics" note, not marking these could result in confusion - namely, the user might think that these functions somehow allow bypassing the isize::MAX byte limit.

Metadata

Metadata

Assignees

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.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