Skip to content

Commit da7aab6

Browse files
committed
added examples of closures
1 parent 90691c8 commit da7aab6

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()), Some(5));
970+
/// assert_eq!(s.find(|c: char| c.is_lowercase()), Some(1));
969971
/// ```
970972
///
971973
/// Not finding the pattern:

0 commit comments

Comments
 (0)