(&self, wc: &mut WhereCollector)
| 69 | } |
| 70 | |
| 71 | fn parse_keyword_tokens(&self, wc: &mut WhereCollector) -> TokenStream { |
| 72 | let Field { var, ty, atom, .. } = self; |
| 73 | let atom = atom.as_ref().expect("parse_keyword_tokens called without atom"); |
| 74 | let condition = atom.equals_atom(format_ident!("c")); |
| 75 | let inner_ty = ty.unpack_option(); |
| 76 | wc.add(&inner_ty); |
| 77 | if ty.is_option() { |
| 78 | quote! { |
| 79 | let #var = { |
| 80 | let c = p.peek_n(1); |
| 81 | if #condition { |
| 82 | Some(p.parse::<#inner_ty>()?) |
| 83 | } else { |
| 84 | None |
| 85 | } |
| 86 | }; |
| 87 | } |
| 88 | } else { |
| 89 | quote! { |
| 90 | let #var = { |
| 91 | let c = p.peek_n(1); |
| 92 | if #condition { |
| 93 | p.parse::<#inner_ty>()? |
| 94 | } else { |
| 95 | return Err(crate::Diagnostic::new(c, crate::Diagnostic::unexpected))?; |
| 96 | } |
| 97 | }; |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | fn parse_normal_tokens(&self, parse_mode: FieldParseMode, wc: &mut WhereCollector) -> TokenStream { |
| 103 | let Field { var, ty, arg, .. } = self; |
no test coverage detected