MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / map_initializer_list

Method map_initializer_list

cel/src/parser/parser.rs:299–335  ·  view source on GitHub ↗
(&mut self, ctx: &MapInitializerListContextAll)

Source from the content-addressed store, hash-verified

297 }
298
299 fn map_initializer_list(&mut self, ctx: &MapInitializerListContextAll) -> Vec<IdedEntryExpr> {
300 if ctx.keys.is_empty() {
301 return vec![];
302 }
303 let mut entries = Vec::with_capacity(ctx.cols.len());
304 let keys = &ctx.keys;
305 let vals = &ctx.values;
306 for (i, col) in ctx.cols.iter().enumerate() {
307 if i >= keys.len() || i >= vals.len() {
308 return vec![];
309 }
310 let id = self.helper.next_id(col);
311 let key = self.visit(keys[i].as_ref());
312 let is_optional = match (keys[i].opt.as_ref(), self.enable_optional_syntax) {
313 (Some(opt), false) => {
314 self.report_error::<ParseError, _>(
315 opt.as_ref(),
316 None,
317 "unsupported syntax '?'",
318 );
319 continue;
320 }
321 (Some(_), true) => true,
322 (None, _) => false,
323 };
324 let value = self.visit(vals[i].as_ref());
325 entries.push(IdedEntryExpr {
326 id,
327 expr: EntryExpr::MapEntry(MapEntryExpr {
328 key,
329 value,
330 optional: is_optional,
331 }),
332 })
333 }
334 entries
335 }
336
337 fn list_initializer_list(&mut self, ctx: &ListInitContextAll) -> (Vec<IdedExpr>, Vec<usize>) {
338 let mut list = Vec::default();

Callers 1

visit_CreateStructMethod · 0.80

Calls 4

next_idMethod · 0.80
visitMethod · 0.80
pushMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected