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

Function lex_embedded_element

src/repr/src/strconv.rs:1219–1238  ·  view source on GitHub ↗
(buf: &mut LexBuf<'a>)

Source from the content-addressed store, hash-verified

1217}
1218
1219fn lex_embedded_element<'a>(buf: &mut LexBuf<'a>) -> Result<Cow<'a, str>, String> {
1220 let pos = buf.pos();
1221 assert!(matches!(buf.next(), Some('{')));
1222 let mut depth = 1;
1223 let mut in_escape = false;
1224 while depth > 0 {
1225 match buf.next() {
1226 Some('\\') => {
1227 buf.next(); // Next character is escaped, so ignore it
1228 }
1229 Some('"') => in_escape = !in_escape, // Begin or end escape
1230 Some('{') if !in_escape => depth += 1,
1231 Some('}') if !in_escape => depth -= 1,
1232 Some(_) => (),
1233 None => bail!("unterminated embedded element"),
1234 }
1235 }
1236 let s = &buf.inner()[pos..buf.pos()];
1237 Ok(Cow::Borrowed(s))
1238}
1239
1240// Result of `None` indicates element is NULL.
1241fn lex_unquoted_element<'a>(

Callers 2

parse_list_innerFunction · 0.85
parse_map_innerFunction · 0.85

Calls 3

posMethod · 0.80
nextMethod · 0.45
innerMethod · 0.45

Tested by

no test coverage detected