Skip to content

Commit a4e9c39

Browse files
committed
Clarify last element in str.{r,}splitn documentation
1 parent 75df685 commit a4e9c39

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/libcollections/str.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,10 @@ impl str {
10531053
}
10541054

10551055
/// An iterator over substrings of the given string slice, separated by a
1056-
/// pattern, restricted to returning at most `count` items.
1056+
/// pattern, restricted to returning at most `n` items.
10571057
///
1058-
/// The last element returned, if any, will contain the remainder of the
1059-
/// string slice.
1058+
/// If `n` substrings are returned, the last substring (the `n`th substring)
1059+
/// will contain the remainder of the string.
10601060
///
10611061
/// The pattern can be a `&str`, [`char`], or a closure that determines the
10621062
/// split.
@@ -1098,16 +1098,16 @@ impl str {
10981098
/// assert_eq!(v, ["abc", "defXghi"]);
10991099
/// ```
11001100
#[stable(feature = "rust1", since = "1.0.0")]
1101-
pub fn splitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> SplitN<'a, P> {
1102-
core_str::StrExt::splitn(self, count, pat)
1101+
pub fn splitn<'a, P: Pattern<'a>>(&'a self, n: usize, pat: P) -> SplitN<'a, P> {
1102+
core_str::StrExt::splitn(self, n, pat)
11031103
}
11041104

11051105
/// An iterator over substrings of this string slice, separated by a
11061106
/// pattern, starting from the end of the string, restricted to returning
1107-
/// at most `count` items.
1107+
/// at most `n` items.
11081108
///
1109-
/// The last element returned, if any, will contain the remainder of the
1110-
/// string slice.
1109+
/// If `n` substrings are returned, the last substring (the `n`th substring)
1110+
/// will contain the remainder of the string.
11111111
///
11121112
/// The pattern can be a `&str`, [`char`], or a closure that
11131113
/// determines the split.
@@ -1145,10 +1145,10 @@ impl str {
11451145
/// assert_eq!(v, ["ghi", "abc1def"]);
11461146
/// ```
11471147
#[stable(feature = "rust1", since = "1.0.0")]
1148-
pub fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P>
1148+
pub fn rsplitn<'a, P: Pattern<'a>>(&'a self, n: usize, pat: P) -> RSplitN<'a, P>
11491149
where P::Searcher: ReverseSearcher<'a>
11501150
{
1151-
core_str::StrExt::rsplitn(self, count, pat)
1151+
core_str::StrExt::rsplitn(self, n, pat)
11521152
}
11531153

11541154
/// An iterator over the matches of a pattern within the given string

0 commit comments

Comments
 (0)