Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HomogeneousTuple / TupleCollect for N > 4 ? #428

Closed
Boscop opened this issue Mar 13, 2020 · 1 comment · Fixed by #475
Closed

HomogeneousTuple / TupleCollect for N > 4 ? #428

Boscop opened this issue Mar 13, 2020 · 1 comment · Fixed by #475

Comments

@Boscop
Copy link

Boscop commented Mar 13, 2020

It would be useful to have HomogeneousTuple / TupleCollect for N larger than 4.
E.g. I often use it with splitn to avoid allocations, like:

s.splitn(N, pattern).collect_tuple()

instead of

if let [/* ... */] = pattern.splitn(N, pattern).collect_vec().as_slice() {
	Some(/* ... */)
} else {
	None
}

And often my N is higher than 4.

@jswrenn
Copy link
Member

jswrenn commented Mar 23, 2020

I'll happily accept a pull request for this!

jswrenn added a commit to jswrenn/rust-itertools that referenced this issue Sep 4, 2020
following the convention of libcore

fixes rust-itertools#428
fixes rust-itertools#398
phimuemue pushed a commit to phimuemue/rust-itertools that referenced this issue Sep 19, 2020
following the convention of libcore

fixes rust-itertools#428
fixes rust-itertools#398
bors bot added a commit that referenced this issue Sep 22, 2020
475: Trait impls for tuples of arity <= 12 r=jswrenn a=jswrenn

I stopped at 12, because that's where libcore stops.

fixes #428
fixes #398

476: Undeprecate and optimize `fold_while` r=jswrenn a=jswrenn

Prompted by #469.

479: fix compiler warning on array.into_iter() r=jswrenn a=dmitris

Fix the compile warnings listed below by changing `into_iter()` invocation to `iter()` 
in the `impl_zip_iter` macro as recommended in rust-lang/rust#66145.
For additional background, see also rust-lang/rust#65819 and rust-lang/rust#66017 (the latter is the linter change producing the warning).

```
$ cargo build
   Compiling itertools v0.9.0 (/Users/dsavints/dev/hack/github.com/rust-itertools/itertools)
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
   --> src/ziptuple.rs:111:47
    |
111 |                 let size = *[$( $B.len(), )*].into_iter().min().unwrap();
    |                                               ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
...
128 | impl_zip_iter!(A);
    | ------------------ in this macro invocation
    |
    = note: `#[warn(array_into_iter)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #66145 <rust-lang/rust#66145>
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
   --> src/ziptuple.rs:111:47
    |
111 |                 let size = *[$( $B.len(), )*].into_iter().min().unwrap();
    |                                               ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
...
129 | impl_zip_iter!(A, B);
    | --------------------- in this macro invocation
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #66145 <rust-lang/rust#66145>
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
```

Co-authored-by: Jack Wrenn <me@jswrenn.com>
Co-authored-by: Dmitry Savintsev <dsavints@verizonmedia.com>
@bors bors bot closed this as completed in d03c37b Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants