rust-lang/rust

String methods do not acknowladge isize::MAX limit like Vec methods do

Opened this issue · 3 comments

Location (URL)

https://doc.rust-lang.org/nightly/std/string/struct.String.html#method.reserve

Summary

All the Vec methods that allocate give a disclaimer about how Rust allocations can't exceed isize::MAX bytes, however, (most) String methods that allocate do not have the same disclaimer.

reserve and reserve_exact are the worst here, as they actually have the wrong disclaimer, claiming the limit is usize::MAX instead!

Oh, wow, the "reserve panics if the new capacity overflows usize" claim dates back to when the type was still called uint 🙃

I'd like to work on this.

@leftmostcat cc me in the PR.