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>,
)
| 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 | } |