added examples of closures
This commit is contained in:
parent
90691c8c1f
commit
da7aab6e51
1 changed files with 3 additions and 1 deletions
|
@ -959,13 +959,15 @@ impl str {
|
||||||
/// assert_eq!(s.find("Léopard"), Some(13));
|
/// 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";
|
/// let s = "Löwe 老虎 Léopard";
|
||||||
///
|
///
|
||||||
/// assert_eq!(s.find(char::is_whitespace), Some(5));
|
/// assert_eq!(s.find(char::is_whitespace), Some(5));
|
||||||
/// assert_eq!(s.find(char::is_lowercase), Some(1));
|
/// assert_eq!(s.find(char::is_lowercase), Some(1));
|
||||||
|
/// assert_eq!(s.find(|c: char| c.is_whitespace()), Some(5));
|
||||||
|
/// assert_eq!(s.find(|c: char| c.is_lowercase()), Some(1));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Not finding the pattern:
|
/// Not finding the pattern:
|
||||||
|
|
Loading…
Reference in a new issue