rust/src/libcore/iter
bors a7be40c65a Auto merge of #56534 - xfix:copied, r=@SimonSapin
Add unstable Iterator::copied()

Initially suggested at https://github.com/bluss/rust-itertools/pull/289, however the maintainers of itertools suggested this may be better of in a standard library.

The intent of `copied` is to avoid accidentally cloning iterator elements after doing a code refactoring which causes a structure to be no longer `Copy`. This is a relatively common pattern, as it can be seen by calling `rg --pcre2 '[.]map[(][|](?:(\w+)[|] [*]\1|&(\w+)[|] \2)[)]'` on Rust main repository. Additionally, many uses of `cloned` actually want to simply `Copy`, and changing something to be no longer copyable may introduce unnoticeable performance penalty.

Also, this makes sense because the standard library includes `[T].copy_from_slice` to pair with `[T].clone_from_slice`.

This also adds `Option::copied`, because it makes sense to pair it with `Iterator::copied`. I don't think this feature is particularly important, but it makes sense to update `Option` along with `Iterator` for consistency.
2018-12-26 19:39:19 +00:00
..
iterator.rs Auto merge of #56534 - xfix:copied, r=@SimonSapin 2018-12-26 19:39:19 +00:00
mod.rs Auto merge of #56534 - xfix:copied, r=@SimonSapin 2018-12-26 19:39:19 +00:00
range.rs Remove licenses 2018-12-25 21:08:33 -07:00
sources.rs Remove licenses 2018-12-25 21:08:33 -07:00
traits.rs Remove licenses 2018-12-25 21:08:33 -07:00