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

Add as_str method for split whitespace str iterators #82570

Merged
merged 2 commits into from
Mar 20, 2021

Conversation

WaffleLapkin
Copy link
Member

This PR adds as_str methods to SplitWhitespace and SplitAsciiWhitespace
str iterators. The methods return the remainder, similar to as_str methods on
Chars and other split iterators. This PR is a continuation of #75265, which added as_str for all other str split iterators.

The feature gate for new methods is #![feature(str_split_whitespace_as_str)].

SplitWhitespace and SplitAsciiWhitespace use iterators under the hood, so to implement as_str it's required to either

  1. Make fields of some iterators pub(crate)
  2. Add getter methods (like into_inner, inner, inner_mut...) to some (all) iterators
  3. Completely rewrite SplitWhitespace and SplitAsciiWhitespace

This PR uses the 1. approach since it's easier to implement and requires fewer changes (and no changes to the public API). If you think that's not the right way, please, tell me.

r? @m-ou-se

This commit adds `as_str` methods to `SplitWhitespace` and `SplitAsciiWhitespace`
str iterators. The methods return the remainder, similar to `as_str` methods on
`Chars` and other split iterators.

This commit also makes fields of some iterators `pub(crate)`.
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 26, 2021
@rust-log-analyzer

This comment has been minimized.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 16, 2021
@Dylan-DPC-zz
Copy link

@m-ou-se this is ready for review

@m-ou-se
Copy link
Member

m-ou-se commented Mar 19, 2021

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 19, 2021

📌 Commit d4fd853 has been approved by m-ou-se

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 19, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 19, 2021
Rollup of 8 pull requests

Successful merges:

 - rust-lang#79986 (Only build help popup when it's really needed)
 - rust-lang#82570 (Add `as_str` method for split whitespace str iterators)
 - rust-lang#83244 (Fix overflowing length in Vec<ZST> to VecDeque)
 - rust-lang#83254 (Include output stream in `panic!()` documentation)
 - rust-lang#83269 (Revert the second deprecation of collections::Bound)
 - rust-lang#83277 (Mark early otherwise optimization unsound)
 - rust-lang#83285 (Update LLVM to bring in SIMD updates for WebAssembly)
 - rust-lang#83297 (Do not ICE on ty::Error as an error must already have been reported)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f7febc8 into rust-lang:master Mar 20, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 20, 2021
@WaffleLapkin WaffleLapkin deleted the split_whitespace_as_str branch March 20, 2021 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants