9

Github Add `as_str` method for split whitespace str iterators by WaffleLapkin ·...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/82570
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

WaffleLapkin commented on Feb 26

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK