As Layout::array's document said, when the total size would exceed isize::MAX, returns LayoutError. Not the usize::MAX.
|
// `Layout::array` checks that the number of bytes is <= usize::MAX, |
|
// but this is redundant since old_layout.size() <= isize::MAX, |
|
// so the `unwrap` should never fail. |
|
let new_layout = Layout::array::<T>(new_cap).unwrap(); |
|
(new_cap, new_layout) |
As
Layout::array's document said, when the total size would exceedisize::MAX, returnsLayoutError. Not theusize::MAX.nomicon/src/vec/vec-alloc.md
Lines 178 to 182 in 0d5f884