rust/compiler/rustc_expand/src
Dylan DPC b2e254318d
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
2021-03-27 20:37:07 +01:00
..
mbe Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
mut_visit ast: Stop using Mod in Crate 2021-02-18 13:07:49 +03:00
parse ast: Keep expansion status for out-of-line module items 2021-02-18 13:07:49 +03:00
tokenstream mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
base.rs Rollup merge of #83168 - Aaron1011:lint-procedural-masquerade, r=petrochenkov 2021-03-18 00:28:10 +01:00
build.rs ast: Reduce size of ExprKind by boxing fields of ExprKind::Struct 2021-03-16 11:41:24 +03:00
config.rs Move full configuration logic from rustc_expand to rustc_builtin_macros 2021-03-07 00:17:31 +03:00
expand.rs Ban custom inner attributes in expressions and statements 2021-03-25 18:05:30 -04:00
lib.rs Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
mbe.rs Revert "Promote missing_fragment_specifier to hard error" 2020-12-22 09:33:16 -05:00
module.rs expand: Resolve and expand inner attributes on out-of-line modules 2021-03-14 18:10:29 +03:00
placeholders.rs ast/hir: Rename field-related structures 2021-03-16 11:41:24 +03:00
proc_macro_server.rs Extend proc_macro_back_compat lint to js-sys 2021-03-19 14:40:20 -04:00
proc_macro.rs Extend proc_macro_back_compat lint to procedural-masquerade 2021-03-15 16:00:49 -04:00
tests.rs remove redundant closures (clippy::redundant_closure) 2021-01-03 13:34:24 +01:00