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

Method parse

src/ore-proc/src/static_list.rs:178–221  ·  view source on GitHub ↗
(input: syn::parse::ParseStream)

Source from the content-addressed store, hash-verified

176
177impl Parse for StaticListArgs {
178 fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
179 let mut ty: Option<LitStr> = None;
180 let mut name: Option<LitStr> = None;
181 let mut expected_count: Option<LitInt> = None;
182
183 while !input.is_empty() {
184 let lookahead = input.lookahead1();
185 if lookahead.peek(keywords::ty) {
186 let res = input.parse::<KeyValueArg<keywords::ty, LitStr>>()?;
187 ty = Some(res.val);
188 } else if lookahead.peek(keywords::name) {
189 let res = input.parse::<KeyValueArg<keywords::name, LitStr>>()?;
190 name = Some(res.val);
191 } else if lookahead.peek(keywords::expected_count) {
192 let res = input.parse::<KeyValueArg<keywords::expected_count, LitInt>>()?;
193 expected_count = Some(res.val);
194 } else if lookahead.peek(Token![,]) {
195 let _ = input.parse::<Token![,]>()?;
196 } else {
197 return Err(input.error("Unexpected argument"));
198 }
199 }
200
201 let mut missing_args = Vec::new();
202 if ty.is_none() {
203 missing_args.push("ty");
204 }
205 if name.is_none() {
206 missing_args.push("name");
207 }
208 if expected_count.is_none() {
209 missing_args.push("expected_count");
210 }
211
212 if !missing_args.is_empty() {
213 input.error(format!("Missing arguments {:?}", missing_args));
214 }
215
216 Ok(StaticListArgs {
217 ty: ty.expect("checked above"),
218 name: name.expect("checked above"),
219 expected_count: expected_count.expect("checked above"),
220 })
221 }
222}
223
224fn type_matches(static_ty: &Type, expected_ty: &LitStr) -> bool {

Callers 12

parse_k8s_quantityFunction · 0.45
into_service_eventMethod · 0.45
from_secret_nameFunction · 0.45
listMethod · 0.45
parse_refMethod · 0.45
from_strMethod · 0.45
from_strMethod · 0.45
to_socket_addrsMethod · 0.45
resolve_addressFunction · 0.45
dns.rsFile · 0.45
parse_argFunction · 0.45
applyMethod · 0.45

Calls 6

is_noneMethod · 0.80
expectMethod · 0.80
is_emptyMethod · 0.45
peekMethod · 0.45
errorMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected