Searches the remaining buffer for the first character to fail to satisfy `predicate`, returning the string from the current cursor position to the failing character. Advances the cursor to the character that failed the predicate, or to the end of the string if no character failed the predicate.
(&mut self, mut predicate: P)
| 117 | /// Advances the cursor to the character that failed the predicate, or to |
| 118 | /// the end of the string if no character failed the predicate. |
| 119 | pub fn take_while<P>(&mut self, mut predicate: P) -> &'a str |
| 120 | where |
| 121 | P: FnMut(char) -> bool, |
| 122 | { |
| 123 | let pos = self.pos; |
| 124 | while let Some(ch) = self.peek() { |
| 125 | if predicate(ch) { |
| 126 | self.next(); |
| 127 | } else { |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | &self.buf[pos..self.pos] |
| 132 | } |
| 133 | |
| 134 | /// Reports the current position of the cursor in the buffer. |
| 135 | pub fn pos(&self) -> usize { |
no test coverage detected