rust/library
Josh Stone 974bc455ee Specialize flattening iterators with only one inner item
For iterators like `Once` and `option::IntoIter` that only ever have a
single item at most, the front and back iterator states in `FlatMap` and
`Flatten` are a waste, as they're always consumed already. We can use
specialization for these types to simplify the iterator methods.

It's a somewhat common pattern to use `flatten()` for options and
results, even recommended by [multiple][1] [clippy][2] [lints][3]. The
implementation is more efficient with `filter_map`, as mentioned in
[clippy#9377], but this new specialization should close some of that
gap for existing code that flattens.

[1]: https://rust-lang.github.io/rust-clippy/master/#filter_map_identity
[2]: https://rust-lang.github.io/rust-clippy/master/#option_filter_map
[3]: https://rust-lang.github.io/rust-clippy/master/#result_filter_map
[clippy#9377]: https://github.com/rust-lang/rust-clippy/issues/9377
2024-02-16 13:49:29 -08:00
..
alloc Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnay 2024-02-16 07:46:31 +00:00
backtrace@6145fe6bac
core Specialize flattening iterators with only one inner item 2024-02-16 13:49:29 -08:00
panic_abort rustc: implement support for riscv32im_risc0_zkvm_elf 2024-01-22 10:07:36 -08:00
panic_unwind Step all bootstrap cfgs forward 2024-02-08 07:44:34 -05:00
portable-simd Disable conversions between portable_simd and stdarch on big-endian ARM 2024-01-30 04:47:01 +00:00
proc_macro Auto merge of #116385 - kornelski:maybe-rename, r=Amanieu 2024-02-16 14:11:10 +00:00
profiler_builtins Add support for custom JSON targets when using build-std. 2024-02-05 10:20:42 +00:00
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Auto merge of #120538 - kornelski:read-not-exact, r=m-ou-se 2024-02-16 11:53:05 +00:00
stdarch@5ef6eb42bd Update stdarch submodule 2024-01-30 03:33:12 +00:00
sysroot
test Actually abort in panic-abort-tests 2024-01-30 18:19:49 -08:00
unwind Enable Static Builds for FreeBSD 2024-01-11 15:26:16 +00:00