diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 11:28:34 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 13:29:42 -0700 |
| commit | e98dce3e00a7b6bfd264418ef993bbf9cdb1f0b6 (patch) | |
| tree | 1569b4aa8d412df9c49904b8bddeb44d8d4ecef2 /src/libcoretest | |
| parent | d528aa9960cb9b937d8ef6c09905a6a8076d5f3a (diff) | |
| download | rust-e98dce3e00a7b6bfd264418ef993bbf9cdb1f0b6.tar.gz rust-e98dce3e00a7b6bfd264418ef993bbf9cdb1f0b6.zip | |
std: Changing the meaning of the count to splitn
This commit is an implementation of [RFC 979][rfc] which changes the meaning of the count parameter to the `splitn` function on strings and slices. The parameter now means the number of items that are returned from the iterator, not the number of splits that are made. [rfc]: https://github.com/rust-lang/rfcs/pull/979 Closes #23911 [breaking-change]
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/str.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcoretest/str.rs b/src/libcoretest/str.rs index c935b554574..5fce527d979 100644 --- a/src/libcoretest/str.rs +++ b/src/libcoretest/str.rs @@ -65,20 +65,20 @@ fn test_strslice_contains() { fn test_rsplitn_char_iterator() { let data = "\nMäry häd ä little lämb\nLittle lämb\n"; - let mut split: Vec<&str> = data.rsplitn(3, ' ').collect(); + let mut split: Vec<&str> = data.rsplitn(4, ' ').collect(); split.reverse(); assert_eq!(split, ["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); - let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == ' ').collect(); + let mut split: Vec<&str> = data.rsplitn(4, |c: char| c == ' ').collect(); split.reverse(); assert_eq!(split, ["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]); // Unicode - let mut split: Vec<&str> = data.rsplitn(3, 'ä').collect(); + let mut split: Vec<&str> = data.rsplitn(4, 'ä').collect(); split.reverse(); assert_eq!(split, ["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); - let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == 'ä').collect(); + let mut split: Vec<&str> = data.rsplitn(4, |c: char| c == 'ä').collect(); split.reverse(); assert_eq!(split, ["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]); } |
