Skip to content

Commit

Permalink
Rollup merge of rust-lang#45349 - christianpoveda:closures_str_find, …
Browse files Browse the repository at this point in the history
…r=steveklabnik

added examples of closures for str::find

This is an attempt to fix rust-lang#45327

r? @steveklabnik
  • Loading branch information
kennytm committed Oct 19, 2017
2 parents 7da795b + 2a889eb commit 207dab5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 207dab5

Please sign in to comment.