diff options
| author | Lynoure Braakman <lynoure@gmail.com> | 2020-07-13 17:41:27 +0200 |
|---|---|---|
| committer | Lynoure Braakman <lynoure@gmail.com> | 2020-07-13 17:41:27 +0200 |
| commit | d27e7d04a15e29b093fcad97900269f408879c46 (patch) | |
| tree | 0828e1d9b98b1bfe99a9a97f489970a0684a78b1 | |
| parent | e59b08e62ea691916d2f063cac5aab4634128022 (diff) | |
| download | rust-d27e7d04a15e29b093fcad97900269f408879c46.tar.gz rust-d27e7d04a15e29b093fcad97900269f408879c46.zip | |
Clarify the description for rfind
Changes the example code to illustrate the difference between find and rfind
| -rw-r--r-- | src/libcore/str/mod.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 0014501d2c4..fdcd56b9dff 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -3158,11 +3158,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: @@ -3190,8 +3190,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. /// @@ -3207,10 +3207,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: |
