rust/library
bors 6672c16afc Auto merge of #121204 - cuviper:flatten-one-shot, r=the8472
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-17 20:18:54 +00:00
..
alloc Rollup merge of #121149 - SebastianJL:patch-1, r=Mark-Simulacrum 2024-02-17 18:47:41 +01:00
backtrace@6145fe6bac
core Auto merge of #121204 - cuviper:flatten-one-shot, r=the8472 2024-02-17 20:18:54 +00:00
panic_abort
panic_unwind
portable-simd
proc_macro Auto merge of #116385 - kornelski:maybe-rename, r=Amanieu 2024-02-16 14:11:10 +00:00
profiler_builtins
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #119032 - smmalis37:patch-1, r=ChrisDenton 2024-02-17 11:23:03 +01:00
stdarch@5ef6eb42bd
sysroot
test
unwind