Parse a dot operation: .await, .field, .method(), or .0 Pushes the parsed operation(s) into the provided Vec
(
input: syn::parse::ParseStream,
ops: &mut Vec<FieldOperation>,
)
| 281 | /// Parse a dot operation: .await, .field, .method(), or .0 |
| 282 | /// Pushes the parsed operation(s) into the provided Vec |
| 283 | fn parse_one_dot_into( |
| 284 | input: syn::parse::ParseStream, |
| 285 | ops: &mut Vec<FieldOperation>, |
| 286 | ) -> syn::Result<()> { |
| 287 | let dot_span = input.span(); |
| 288 | let _: Token![.] = input.parse()?; |
| 289 | |
| 290 | if input.peek(Token![await]) { |
| 291 | let await_span = input.span(); |
| 292 | let _: Token![await] = input.parse()?; |
| 293 | ops.push(FieldOperation::Await { span: await_span }); |
| 294 | Ok(()) |
| 295 | } else if input.peek(syn::LitInt) { |
| 296 | // It's a tuple index like .0 or .1 |
| 297 | let lit_int: syn::LitInt = input.parse()?; |
| 298 | let index: usize = lit_int.base10_parse()?; |
| 299 | ops.push(FieldOperation::UnnamedField { |
| 300 | index, |
| 301 | span: dot_span, |
| 302 | }); |
| 303 | Ok(()) |
| 304 | } else if input.peek(syn::LitFloat) { |
| 305 | let lit_float: syn::LitFloat = input.parse()?; |
| 306 | // Parse float like "0.0" and split into two UnnamedField operations |
| 307 | let float_str = lit_float.to_string(); |
| 308 | let Some((first, second)) = float_str.split_once('.') else { |
| 309 | return Err(syn::Error::new( |
| 310 | dot_span, |
| 311 | "Invalid float literal in field access", |
| 312 | )); |
| 313 | }; |
| 314 | |
| 315 | let first_idx = first |
| 316 | .parse::<usize>() |
| 317 | .map_err(|_| syn::Error::new(dot_span, "Invalid numeric index in field access"))?; |
| 318 | let second_idx = second |
| 319 | .parse::<usize>() |
| 320 | .map_err(|_| syn::Error::new(dot_span, "Invalid numeric index in field access"))?; |
| 321 | |
| 322 | // Push two sequential UnnamedField operations |
| 323 | ops.push(FieldOperation::UnnamedField { |
| 324 | index: first_idx, |
| 325 | span: dot_span, |
| 326 | }); |
| 327 | ops.push(FieldOperation::UnnamedField { |
| 328 | index: second_idx, |
| 329 | span: dot_span, |
| 330 | }); |
| 331 | Ok(()) |
| 332 | } else { |
| 333 | // Parse as identifier for named field |
| 334 | let ident: syn::Ident = input.parse()?; |
| 335 | |
| 336 | // Check if this is a method call |
| 337 | if input.peek(syn::token::Paren) { |
| 338 | let args_content; |
| 339 | syn::parenthesized!(args_content in input); |
| 340 |