about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-14 07:39:13 -0700
committerGitHub <noreply@github.com>2020-07-14 07:39:13 -0700
commite8703e88fc79929bb9e96e3ac3e1720bfe0c456c (patch)
tree951b01823c160e434f1e4a7da36cac243dad7095 /src
parent1114f2231a186c712ca6fde5d7d2b8d9ae330769 (diff)
parentd27e7d04a15e29b093fcad97900269f408879c46 (diff)
downloadrust-e8703e88fc79929bb9e96e3ac3e1720bfe0c456c.tar.gz
rust-e8703e88fc79929bb9e96e3ac3e1720bfe0c456c.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/libcore/str/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index 89233259a04..393911675c7 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -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: