Files
rust/library/alloc/src
bors 303e8bd768 Auto merge of #131193 - EFanZh:asserts-vec-len, r=the8472
Asserts the maximum value that can be returned from `Vec::len`

Currently, casting `Vec<i32>` to `Vec<u32>` takes O(1) time:

```rust
// See <https://godbolt.org/z/hxq3hnYKG> for assembly output.
pub fn cast(vec: Vec<i32>) -> Vec<u32> {
    vec.into_iter().map(|e| e as _).collect()
}
```

But the generated assembly is not the same as the identity function, which prevents us from casting `Vec<Vec<i32>>` to `Vec<Vec<u32>>` within O(1) time:

```rust
// See <https://godbolt.org/z/7n48bxd9f> for assembly output.
pub fn cast(vec: Vec<Vec<i32>>) -> Vec<Vec<u32>> {
    vec.into_iter()
        .map(|e| e.into_iter().map(|e| e as _).collect())
        .collect()
}
```

This change tries to fix the problem. You can see the comparison here: <https://godbolt.org/z/jdManrKvx>.
2024-12-22 16:09:16 +00:00
..
2024-11-27 12:10:21 +00:00
2024-08-09 20:06:26 -04:00
2024-12-02 18:16:36 +00:00
2024-07-29 08:26:52 +10:00
2024-12-13 00:04:56 +00:00
2024-12-05 21:48:01 +01:00
2024-12-13 00:04:56 +00:00
2024-07-06 14:24:20 +02:00
2024-12-17 14:33:10 -08:00
2024-11-06 18:54:50 +00:00
2024-12-05 14:14:17 -08:00