(s: &str, mut predicate: P)
| 35 | } |
| 36 | |
| 37 | fn take_while<P>(s: &str, mut predicate: P) -> &str |
| 38 | where |
| 39 | P: FnMut(char) -> bool, |
| 40 | { |
| 41 | let offset = s |
| 42 | .chars() |
| 43 | .take_while(|ch| predicate(*ch)) |
| 44 | .map(|ch| ch.len_utf8()) |
| 45 | .sum(); |
| 46 | &s[..offset] |
| 47 | } |
| 48 | |
| 49 | fn skip_while<P>(s: &str, mut predicate: P) -> &str |
| 50 | where |