Skip to content

Commit e8703e8

Browse files
authored
Rollup merge of #74296 - Lynoure:rfind-doc-improvement, r=hanna-kruppe
Clarify the description for rfind Changes the wording in rfind description to be clearer and the example code to illustrate the difference between find and rfind
2 parents 1114f22 + d27e7d0 commit e8703e8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/libcore/str/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -3156,11 +3156,11 @@ impl str {
31563156
/// Simple patterns:
31573157
///
31583158
/// ```
3159-
/// let s = "Löwe 老虎 Léopard";
3159+
/// let s = "Löwe 老虎 Léopard Gepardi";
31603160
///
31613161
/// assert_eq!(s.find('L'), Some(0));
31623162
/// assert_eq!(s.find('é'), Some(14));
3163-
/// assert_eq!(s.find("Léopard"), Some(13));
3163+
/// assert_eq!(s.find("pard"), Some(17));
31643164
/// ```
31653165
///
31663166
/// More complex patterns using point-free style and closures:
@@ -3188,8 +3188,8 @@ impl str {
31883188
pat.into_searcher(self).next_match().map(|(i, _)| i)
31893189
}
31903190

3191-
/// Returns the byte index of the last character of this string slice that
3192-
/// matches the pattern.
3191+
/// Returns the byte index for the first character of the rightmost match of the pattern in
3192+
/// this string slice.
31933193
///
31943194
/// Returns [`None`] if the pattern doesn't match.
31953195
///
@@ -3205,10 +3205,11 @@ impl str {
32053205
/// Simple patterns:
32063206
///
32073207
/// ```
3208-
/// let s = "Löwe 老虎 Léopard";
3208+
/// let s = "Löwe 老虎 Léopard Gepardi";
32093209
///
32103210
/// assert_eq!(s.rfind('L'), Some(13));
32113211
/// assert_eq!(s.rfind('é'), Some(14));
3212+
/// assert_eq!(s.rfind("pard"), Some(24));
32123213
/// ```
32133214
///
32143215
/// More complex patterns with closures:

0 commit comments

Comments
 (0)