about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2017-10-19 23:13:28 +0800
committerkennytm <kennytm@gmail.com>2017-10-20 00:01:51 +0800
commit207dab577330be6da19094c4ff1fbc1988464ecf (patch)
treeadacc9641e661f46a8e16891a0df24e60b13f0cb /src/liballoc
parent7da795ba10037050872d97642aed9bdcb9926ff3 (diff)
parent2a889eb945cdae95fce33fbeb1b79093c456cadd (diff)
downloadrust-207dab577330be6da19094c4ff1fbc1988464ecf.tar.gz
rust-207dab577330be6da19094c4ff1fbc1988464ecf.zip
Rollup merge of #45349 - christianpoveda:closures_str_find, r=steveklabnik
added examples of closures for str::find

This is an attempt to fix https://github.com/rust-lang/rust/issues/45327

r? @steveklabnik
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/str.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs
index 830128f2b9f..895607ff8d4 100644
--- a/src/liballoc/str.rs
+++ b/src/liballoc/str.rs
@@ -959,13 +959,15 @@ impl str {
     /// assert_eq!(s.find("Léopard"), Some(13));
     /// ```
     ///
-    /// More complex patterns with closures:
+    /// More complex patterns using point-free style and closures:
     ///
     /// ```
     /// let s = "Löwe 老虎 Léopard";
     ///
     /// assert_eq!(s.find(char::is_whitespace), Some(5));
     /// assert_eq!(s.find(char::is_lowercase), Some(1));
+    /// assert_eq!(s.find(|c: char| c.is_whitespace() || c.is_lowercase()), Some(1));
+    /// assert_eq!(s.find(|c: char| (c < 'o') && (c > 'a')), Some(4));
     /// ```
     ///
     /// Not finding the pattern: