Skip to content

Commit

Permalink
Rollup merge of #74296 - Lynoure:rfind-doc-improvement, r=hanna-kruppe
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Manishearth committed Jul 14, 2020
2 parents 1114f22 + d27e7d0 commit e8703e8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3156,11 +3156,11 @@ impl str {
/// Simple patterns:
///
/// ```
/// let s = "Löwe 老虎 Léopard";
/// let s = "Löwe 老虎 Léopard Gepardi";
///
/// assert_eq!(s.find('L'), Some(0));
/// assert_eq!(s.find('é'), Some(14));
/// assert_eq!(s.find("Léopard"), Some(13));
/// assert_eq!(s.find("pard"), Some(17));
/// ```
///
/// More complex patterns using point-free style and closures:
Expand Down Expand Up @@ -3188,8 +3188,8 @@ impl str {
pat.into_searcher(self).next_match().map(|(i, _)| i)
}

/// Returns the byte index of the last character of this string slice that
/// matches the pattern.
/// Returns the byte index for the first character of the rightmost match of the pattern in
/// this string slice.
///
/// Returns [`None`] if the pattern doesn't match.
///
Expand All @@ -3205,10 +3205,11 @@ impl str {
/// Simple patterns:
///
/// ```
/// let s = "Löwe 老虎 Léopard";
/// let s = "Löwe 老虎 Léopard Gepardi";
///
/// assert_eq!(s.rfind('L'), Some(13));
/// assert_eq!(s.rfind('é'), Some(14));
/// assert_eq!(s.rfind("pard"), Some(24));
/// ```
///
/// More complex patterns with closures:
Expand Down

0 comments on commit e8703e8

Please sign in to comment.