| 456 | } |
| 457 | |
| 458 | fn 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 | |
| 501 | fn parse_function_config(input: ParseStream<'_>) -> Result<FunctionConfig> { |
| 502 | let content; |