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
..
boxed replace placeholder version 2024-11-27 12:10:21 +00:00
collections Less unwrap() in documentation 2024-12-21 01:26:47 +00:00
ffi Move some alloc tests to the alloctests crate 2024-12-04 14:32:04 +00:00
raw_vec Polymorphize RawVec 2024-08-09 20:06:26 -04:00
rc Use c"lit" for CStrings without unwrap 2024-12-02 18:16:36 +00:00
testing Reformat use declarations. 2024-07-29 08:26:52 +10:00
vec Auto merge of #131193 - EFanZh:asserts-vec-len, r=the8472 2024-12-22 16:09:16 +00:00
alloc.rs Move some alloc tests to the alloctests crate 2024-12-04 14:32:04 +00:00
borrow.rs remove const_cow_is_borrowed feature gate 2024-10-12 19:48:28 +02:00
boxed.rs Stabilize async closures 2024-12-13 00:04:56 +00:00
fmt.rs Added struct fmt::FormattingOptions 2024-12-05 21:48:01 +01:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Stabilize async closures 2024-12-13 00:04:56 +00:00
macros.rs Mark format! with must_use hint 2024-07-06 14:24:20 +02:00
raw_vec.rs Auto merge of #133533 - BoxyUwU:bump-boostrap, r=jieyouxu,Mark-Simulacrum 2024-11-29 22:39:10 +00:00
rc.rs Use field init shorthand where possible 2024-12-17 14:33:10 -08:00
slice.rs Change GetManyMutError to match T-libs-api decision 2024-11-28 23:34:47 +02:00
str.rs Inline str::repeat 2024-11-06 18:54:50 +00:00
string.rs Remove support for specializing ToString outside the standard library 2024-12-13 13:48:19 +00:00
sync.rs Use field init shorthand where possible 2024-12-17 14:33:10 -08:00
task.rs Stabilize noop_waker 2024-12-05 14:14:17 -08:00