MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / with_field_parse

Function with_field_parse

crates/component-macro/src/bindgen.rs:458–499  ·  view source on GitHub ↗
(input: ParseStream<'_>)

Source from the content-addressed store, hash-verified

456}
457
458fn with_field_parse(input: ParseStream<'_>) -> Result<(String, String)> {
459 let interface = input.parse::<syn::LitStr>()?.value();
460 input.parse::<Token![:]>()?;
461 let start = input.span();
462 let path = input.parse::<syn::Path>()?;
463
464 // It's not possible for the segments of a path to be empty
465 let span = start
466 .join(path.segments.last().unwrap().ident.span())
467 .unwrap_or(start);
468
469 let mut buf = String::new();
470 let append = |buf: &mut String, segment: syn::PathSegment| -> Result<()> {
471 if segment.arguments != syn::PathArguments::None {
472 return Err(Error::new(
473 span,
474 "Module path must not contain angles or parens",
475 ));
476 }
477
478 buf.push_str(&segment.ident.to_string());
479
480 Ok(())
481 };
482
483 if path.leading_colon.is_some() {
484 buf.push_str("::");
485 }
486
487 let mut segments = path.segments.into_iter();
488
489 if let Some(segment) = segments.next() {
490 append(&mut buf, segment)?;
491 }
492
493 for segment in segments {
494 buf.push_str("::");
495 append(&mut buf, segment)?;
496 }
497
498 Ok((interface, buf))
499}
500
501fn parse_function_config(input: ParseStream<'_>) -> Result<FunctionConfig> {
502 let content;

Callers

nothing calls this directly

Calls 11

OkFunction · 0.85
newFunction · 0.50
valueMethod · 0.45
joinMethod · 0.45
unwrapMethod · 0.45
lastMethod · 0.45
push_strMethod · 0.45
to_stringMethod · 0.45
is_someMethod · 0.45
into_iterMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected