about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-03-27 20:37:07 +0100
committerGitHub <noreply@github.com>2021-03-27 20:37:07 +0100
commitb094bb1bd7f1cc702823c91ca509f338fedee24a (patch)
tree7cf36685a6692154eaa25fe2dbbfbf3728e10e71 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parentce4e668e39f710dae60c3d476eb594aebd9da11c (diff)
parent0dddfbf9bf1aaa21df14b08968fd21139a8b9aa3 (diff)
downloadrust-b094bb1bd7f1cc702823c91ca509f338fedee24a.tar.gz
rust-b094bb1bd7f1cc702823c91ca509f338fedee24a.zip
Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se
Add function core::iter::zip

This makes it a little easier to `zip` iterators:

```rust
for (x, y) in zip(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().zip(ys) {}
```

You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
`iter()`, respectively. This can also support arbitrary nesting, where
it's easier to see the item layout than with arbitrary `zip` chains:

```rust
for ((x, y), z) in zip(zip(xs, ys), zs) {}
for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
// vs.
for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
```

It may also format more nicely, especially when the first iterator is a
longer chain of methods -- for example:

```rust
    iter::zip(
        trait_ref.substs.types().skip(1),
        impl_trait_ref.substs.types().skip(1),
    )
    // vs.
    trait_ref
        .substs
        .types()
        .skip(1)
        .zip(impl_trait_ref.substs.types().skip(1))
```

This replaces the tuple-pair `IntoIterator` in #78204.
There is prior art for the utility of this in [`itertools::zip`].

[`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions