MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / take_while

Method take_while

src/ore/src/lex.rs:119–132  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 {

Callers 15

scan_new_bytesMethod · 0.80
last_value_innerFunction · 0.80
parse_identFunction · 0.80
truncate_stringFunction · 0.80
trimMethod · 0.80
writeMethod · 0.80
lex_line_commentFunction · 0.80
lex_identFunction · 0.80
lex_octal_escapeFunction · 0.80
lex_hexadecimal_escapeFunction · 0.80
lex_to_adjacent_stringFunction · 0.80
lex_parameterFunction · 0.80

Calls 2

peekMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected