Skip to content

Commit d27e7d0

Browse files
committed
Clarify the description for rfind
Changes the example code to illustrate the difference between find and rfind
1 parent e59b08e commit d27e7d0

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
@@ -3158,11 +3158,11 @@ impl str {
31583158
/// Simple patterns:
31593159
///
31603160
/// ```
3161-
/// let s = "Löwe 老虎 Léopard";
3161+
/// let s = "Löwe 老虎 Léopard Gepardi";
31623162
///
31633163
/// assert_eq!(s.find('L'), Some(0));
31643164
/// assert_eq!(s.find('é'), Some(14));
3165-
/// assert_eq!(s.find("Léopard"), Some(13));
3165+
/// assert_eq!(s.find("pard"), Some(17));
31663166
/// ```
31673167
///
31683168
/// More complex patterns using point-free style and closures:
@@ -3190,8 +3190,8 @@ impl str {
31903190
pat.into_searcher(self).next_match().map(|(i, _)| i)
31913191
}
31923192

3193-
/// Returns the byte index of the last character of this string slice that
3194-
/// matches the pattern.
3193+
/// Returns the byte index for the first character of the rightmost match of the pattern in
3194+
/// this string slice.
31953195
///
31963196
/// Returns [`None`] if the pattern doesn't match.
31973197
///
@@ -3207,10 +3207,11 @@ impl str {
32073207
/// Simple patterns:
32083208
///
32093209
/// ```
3210-
/// let s = "Löwe 老虎 Léopard";
3210+
/// let s = "Löwe 老虎 Léopard Gepardi";
32113211
///
32123212
/// assert_eq!(s.rfind('L'), Some(13));
32133213
/// assert_eq!(s.rfind('é'), Some(14));
3214+
/// assert_eq!(s.rfind("pard"), Some(24));
32143215
/// ```
32153216
///
32163217
/// More complex patterns with closures:

0 commit comments

Comments
 (0)