Skip to content

Commit 207dab5

Browse files
committed
Rollup merge of rust-lang#45349 - christianpoveda:closures_str_find, r=steveklabnik
added examples of closures for str::find This is an attempt to fix rust-lang#45327 r? @steveklabnik
2 parents 7da795b + 2a889eb commit 207dab5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/liballoc/str.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,13 +959,15 @@ impl str {
959959
/// assert_eq!(s.find("Léopard"), Some(13));
960960
/// ```
961961
///
962-
/// More complex patterns with closures:
962+
/// More complex patterns using point-free style and closures:
963963
///
964964
/// ```
965965
/// let s = "Löwe 老虎 Léopard";
966966
///
967967
/// assert_eq!(s.find(char::is_whitespace), Some(5));
968968
/// assert_eq!(s.find(char::is_lowercase), Some(1));
969+
/// assert_eq!(s.find(|c: char| c.is_whitespace() || c.is_lowercase()), Some(1));
970+
/// assert_eq!(s.find(|c: char| (c < 'o') && (c > 'a')), Some(4));
969971
/// ```
970972
///
971973
/// Not finding the pattern:

0 commit comments

Comments
 (0)