rust/library/core/tests
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
..
async_iter Remove unnecessary lets and borrowing from Waker::noop() usage. 2024-01-17 12:00:27 -08:00
fmt apply fmt 2024-01-11 15:04:48 +03:00
hash apply fmt 2024-01-11 15:04:48 +03:00
io Make io::BorrowedCursor::advance safe 2024-02-07 16:46:28 +01:00
iter Specialize flattening iterators with only one inner item 2024-02-16 13:49:29 -08:00
net Rollup merge of #119081 - jstasiak:is-ipv4-mapped, r=dtolnay 2024-01-21 06:38:35 +01:00
num remove redundant imports 2023-12-10 10:56:22 +08:00
ops
panic
alloc.rs
any.rs Adjust library tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
array.rs Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
ascii.rs
asserting.rs
atomic.rs Adjust library tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
bool.rs
cell.rs apply fmt 2024-01-11 15:04:48 +03:00
char.rs remove redundant imports 2023-12-10 10:56:22 +08:00
clone.rs
cmp.rs
const_ptr.rs
convert.rs
error.rs apply fmt 2024-01-11 15:04:48 +03:00
future.rs
intrinsics.rs Adjust library tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
lazy.rs
lib.rs Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
macros.rs Update tests 2024-02-07 10:42:01 +08:00
manually_drop.rs
mem.rs Rename MaybeUninit::write_slice 2023-11-11 22:54:07 +00:00
nonzero.rs Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
ops.rs
option.rs apply fmt 2024-01-11 15:04:48 +03:00
panic.rs
pattern.rs
pin_macro.rs
pin.rs
ptr.rs Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
result.rs Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
simd.rs Fix library tests 2023-11-26 08:50:39 -05:00
slice.rs Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
str_lossy.rs
str.rs
task.rs
time.rs core: add Duration constructors 2024-01-24 14:24:57 +01:00
tuple.rs
unicode.rs
waker.rs