-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add Iterator::intersperse
#79479
Add Iterator::intersperse
#79479
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
67fd81c
to
b2f144f
Compare
Squashed. |
1ddd660
to
ee18244
Compare
r? @LukasKalbertodt (you're the original reviewer, feel free to re-assign) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
r? @m-ou-se |
Two cents: We could lift the Having thought about it again, I think we'd need a separate |
What would the opinion be on making it support |
The signature for this function is a good question. Since it only clones the separator, a reference to it would suffice. However, that'd make it a bit more complicated in usage, as it'd always be borrowing something, making it a bit tricky with the lifetime in some situations. The most flexible signature would be that of |
I don't want to derail this, as there has already been quite some discussion before in #75784 and related. To reiterate, I just think the To the tune of
|
Could we use |
|
I haven't added a function to libs before, so I'm fine with whatever is agreed upon as long as it's reasonable :) |
Imho the |
@m-ou-se love poke |
Sorry for the delay. This looks good to me. One comment: Should |
Nice, I'd love to see a PR for that. :) |
That seems reasonable. Like you said, though, we can always add it later. I'll defer to you :) |
@bors r+ |
📌 Commit 40bbb7f has been approved by |
Rollup of 9 pull requests Successful merges: - rust-lang#78934 (refactor: removing library/alloc/src/vec/mod.rs ignore-tidy-filelength) - rust-lang#79479 (Add `Iterator::intersperse`) - rust-lang#80128 (Edit rustc_ast::ast::FieldPat docs) - rust-lang#80424 (Don't give an error when creating a file for the first time) - rust-lang#80458 (Some Promotion Refactoring) - rust-lang#80488 (Do not create dangling &T in Weak<T>::drop) - rust-lang#80491 (Miri: make size/align_of_val work for dangling raw ptrs) - rust-lang#80495 (Rename kw::Invalid -> kw::Empty) - rust-lang#80513 (Add regression test for rust-lang#80062) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Should there be a doc alias to join since it is similar? |
Add Iterator::intersperse_with This is a follow-up to rust-lang#79479, tracking in rust-lang#79524, as discussed rust-lang#79479 (comment). ~~Note that I had to manually implement `Clone` and `Debug` because `derive` insists on placing a `Clone`-bound on the struct-definition, which is too narrow. There is a long-standing issue # for this somewhere around here :-)~~ Also, note that I refactored the guts of `Intersperse` into private functions and re-used them in `IntersperseWith`, so I also went light on duplicating all the tests. If this is suitable to be merged, the tracking issue should be updated, since it only mentions `intersperse`. Happy New Year! r? `@m-ou-se`
Add Iterator::intersperse_with This is a follow-up to rust-lang#79479, tracking in rust-lang#79524, as discussed rust-lang#79479 (comment). ~~Note that I had to manually implement `Clone` and `Debug` because `derive` insists on placing a `Clone`-bound on the struct-definition, which is too narrow. There is a long-standing issue # for this somewhere around here :-)~~ Also, note that I refactored the guts of `Intersperse` into private functions and re-used them in `IntersperseWith`, so I also went light on duplicating all the tests. If this is suitable to be merged, the tracking issue should be updated, since it only mentions `intersperse`. Happy New Year! r? ``@m-ou-se``
Fix intersperse_fold Here is a standalone playground link in case anybody wants to modify code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=626b4d044fb74f044a36098ad907e40f Fixes rust-lang#81145 cc rust-lang#79479 `@jonas-schievink`
Fix intersperse_fold Here is a standalone playground link in case anybody wants to modify code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=626b4d044fb74f044a36098ad907e40f Fixes rust-lang#81145 cc rust-lang#79479 ``@jonas-schievink``
Fix intersperse_fold Here is a standalone playground link in case anybody wants to modify code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=626b4d044fb74f044a36098ad907e40f Fixes rust-lang#81145 cc rust-lang#79479 `@jonas-schievink`
This is a rebase of #75784. I'm hoping to push this past the finish line!
cc @jonas-schievink