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

Method atom_match_arm

crates/csskit_derives/src/parse.rs:134–146  ·  view source on GitHub ↗

Emits the atom-conditional match arm used in must-occur loops.

(&self)

Source from the content-addressed store, hash-verified

132
133 /// Emits the atom-conditional match arm used in must-occur loops.
134 fn atom_match_arm(&self) -> TokenStream {
135 let atom = self.atom.as_ref().expect("atom_match_arm called without atom");
136 let atom_path = atom.path();
137 let atom_set = atom.first_segment();
138 let var = &self.var;
139 let inner_ty = self.ty.unpack_option();
140 quote! {
141 if #var.is_none() && p.peek::<#inner_ty>() && p.to_atom::<#atom_set>(c) == #atom_path {
142 #var = Some(p.parse::<#inner_ty>()?);
143 continue;
144 }
145 }
146 }
147
148 /// Emits a simple parse-if-peek for a single atom field.
149 fn atom_parse_if_peek(&self) -> TokenStream {

Callers 2

renderMethod · 0.80
hoisted_preloopMethod · 0.80

Calls 4

as_refMethod · 0.80
pathMethod · 0.80
first_segmentMethod · 0.80
unpack_optionMethod · 0.80

Tested by

no test coverage detected