MCPcopy Create free account
hub / github.com/carllerche/assert-struct / parse_one_into

Method parse_one_into

assert-struct-macros/src/pattern/field.rs:371–393  ·  view source on GitHub ↗

Parse a single operation: .await, .field, .method(), or \[index\] Pushes the parsed operation into the provided Vec

(
        input: syn::parse::ParseStream,
        ops: &mut Vec<FieldOperation>,
    )

Source from the content-addressed store, hash-verified

369 /// Parse a single operation: .await, .field, .method(), or \[index\]
370 /// Pushes the parsed operation into the provided Vec
371 pub(crate) fn parse_one_into(
372 input: syn::parse::ParseStream,
373 ops: &mut Vec<FieldOperation>,
374 ) -> syn::Result<()> {
375 if input.peek(Token![.]) {
376 Self::parse_one_dot_into(input, ops)
377 } else if input.peek(syn::token::Bracket) {
378 // Index operation - need to capture the span that encompasses the bracket
379 let content;
380 let bracket_token = syn::bracketed!(content in input);
381 let index: syn::Expr = content.parse()?;
382 ops.push(FieldOperation::Index {
383 index,
384 span: bracket_token.span.open(),
385 });
386 Ok(())
387 } else {
388 Err(syn::Error::new(
389 input.span(),
390 "Expected field operation (.field, .method(), .await, or [index])",
391 ))
392 }
393 }
394}

Callers

nothing calls this directly

Calls 3

pushMethod · 0.80
parseMethod · 0.45
spanMethod · 0.45

Tested by

no test coverage detected