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
This commit is contained in:
Manish Goregaokar 2020-07-14 07:39:13 -07:00 committed by GitHub
commit e8703e88fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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:
@ -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.
///
@ -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: