rust/library
Chayim Refael Friedman 54556f49d3 Specialize `TrustedLen` for `Iterator::unzip()`
Don't check the capacity every time (and also for `Extend` for tuples, as this is how `unzip()` is implemented).

I did this with an unsafe method on `Extend` that doesn't check for growth (`extend_one_unchecked()`). I've marked it as perma-unstable currently, although we may want to expose it in the future so collections outside of std can benefit from it. Then specialize `Extend for (A, B)` for `TrustedLen` to call it.

It may seem that an alternative way of implementing this is to have a semi-public trait (`#[doc(hidden)]` public, so collections outside of core can implement it) for `extend()` inside tuples, and specialize it from collections. However, it is impossible due to limitations of `min_specialization`.

A concern that may arise with the current approach is that implementing `extend_one_unchecked()` correctly must also incur implementing `extend_reserve()`, otherwise you can have UB. This is a somewhat non-local safety invariant. However, I believe this is fine, since to have actual UB you must have unsafe code inside your `extend_one_unchecked()` that makes incorrect assumption, *and* not implement `extend_reserve()`. I've also documented this requirement.
2024-07-07 06:58:52 +03:00
..
alloc Specialize `TrustedLen` for `Iterator::unzip()` 2024-07-07 06:58:52 +03:00
backtrace@72265bea21 Update backtrace to 0.3.73 2024-06-06 22:50:45 -07:00
core Specialize `TrustedLen` for `Iterator::unzip()` 2024-07-07 06:58:52 +03:00
panic_abort Stabilise c_unwind 2024-06-19 13:54:51 +01:00
panic_unwind Use the native unwind function in miri where possible 2024-07-01 18:02:40 +00:00
portable-simd wasm64 build with target-feature=+simd128,+atomics 2024-06-23 22:58:30 -07:00
proc_macro Add a hack to prevent proc_macro misopt in CI 2024-06-19 13:54:55 +01:00
profiler_builtins Update cc crate to v1.0.97 2024-05-08 15:06:35 +00:00
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #123600 - tisonkun:path_with_extension, r=dtolnay 2024-07-05 20:49:31 -04:00
stdarch@df3618d9f3 feat: update stdarch submodule for intrinsics on ARM 2024-05-15 15:38:58 -04:00
sysroot Add flag to sysroot 2024-05-11 14:31:55 +02:00
test Add blank lines after module-level `//!` comments. 2024-06-20 09:23:20 +10:00
unwind Stabilise c_unwind 2024-06-19 13:54:51 +01:00