mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-21 13:05:14 +00:00
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
This commit is contained in:
commit
207dab5773
@ -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() || c.is_lowercase()), Some(1));
|
||||||
|
/// assert_eq!(s.find(|c: char| (c < 'o') && (c > 'a')), Some(4));
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Not finding the pattern:
|
/// Not finding the pattern:
|
||||||
|
Loading…
Reference in New Issue
Block a user