MCPcopy Create free account
hub / github.com/csskit/csskit / parse

Method parse

crates/css_parse/src/syntax/declaration_list.rs:62–83  ·  view source on GitHub ↗
(p: &mut Parser<'a, Iter>)

Source from the content-addressed store, hash-verified

60 M: NodeMetadata,
61{
62 fn parse<Iter>(p: &mut Parser<'a, Iter>) -> Result<Self>
63 where
64 Iter: Iterator<Item = crate::Cursor> + Clone,
65 {
66 let open_curly = p.parse::<T!['{']>()?;
67 let mut declarations = Vec::new_in(p.bump());
68 let mut meta: M = Default::default();
69 loop {
70 if p.at_end() {
71 meta = meta.with_size(declarations.len().min(u16::MAX as usize) as u16);
72 return Ok(Self { open_curly, declarations, close_curly: None, meta });
73 }
74 let close_curly = p.parse_if_peek::<T!['}']>()?;
75 if close_curly.is_some() {
76 meta = meta.with_size(declarations.len().min(u16::MAX as usize) as u16);
77 return Ok(Self { open_curly, declarations, close_curly, meta });
78 }
79 let declaration = p.parse::<Declaration<'a, V, M>>()?;
80 meta = meta.merge(declaration.metadata());
81 declarations.push(declaration);
82 }
83 }
84}
85
86impl<'a, V, M> ToCursors for DeclarationList<'a, V, M>

Callers

nothing calls this directly

Calls 6

bumpMethod · 0.45
at_endMethod · 0.45
with_sizeMethod · 0.45
lenMethod · 0.45
mergeMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected