MCPcopy Create free account
hub / github.com/dtolnay/thiserror / try_explicit_named_args

Function try_explicit_named_args

impl/src/fmt.rs:192–229  ·  view source on GitHub ↗
(input: ParseStream)

Source from the content-addressed store, hash-verified

190}
191
192fn try_explicit_named_args(input: ParseStream) -> Result<FmtArguments> {
193 let mut syn_full = None;
194 let mut args = FmtArguments {
195 named: BTreeSet::new(),
196 first_unnamed: None,
197 };
198
199 while !input.is_empty() {
200 input.parse::<Token![,]>()?;
201 if input.is_empty() {
202 break;
203 }
204
205 let mut begin_unnamed = None;
206 if input.peek(Ident::peek_any) && input.peek2(Token![=]) && !input.peek2(Token![==]) {
207 let ident: IdentUnraw = input.parse()?;
208 input.parse::<Token![=]>()?;
209 args.named.insert(ident);
210 } else {
211 begin_unnamed = Some(input.fork());
212 }
213
214 let ahead = input.fork();
215 if *syn_full.get_or_insert_with(is_syn_full) && ahead.parse::<Expr>().is_ok() {
216 input.advance_to(&ahead);
217 } else {
218 scan_expr(input)?;
219 }
220
221 if let Some(begin_unnamed) = begin_unnamed {
222 if args.first_unnamed.is_none() {
223 args.first_unnamed = Some(between(&begin_unnamed, input));
224 }
225 }
226 }
227
228 Ok(args)
229}
230
231fn fallback_explicit_named_args(input: ParseStream) -> Result<FmtArguments> {
232 let mut args = FmtArguments {

Callers 1

explicit_named_argsFunction · 0.85

Calls 4

scan_exprFunction · 0.85
betweenFunction · 0.85
parseMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected