more cleanup
This commit is contained in:
parent
0a72d4312f
commit
02e7f5bc0a
2 changed files with 6 additions and 5 deletions
|
@ -48,6 +48,7 @@ impl Parse for OsDisplayAttribute {
|
|||
}
|
||||
|
||||
let lookahead_arg = input.fork();
|
||||
|
||||
if lookahead_arg.peek(Ident) && lookahead_arg.peek2(Token![=]) {
|
||||
let name: Ident = input.parse()?;
|
||||
input.parse::<Token![=]>()?;
|
||||
|
@ -65,7 +66,7 @@ impl Parse for OsDisplayAttribute {
|
|||
named_args,
|
||||
}))
|
||||
} else {
|
||||
Err(lookahead.error())
|
||||
Err(input.error("expected `transparent`, `from_display`, or a format string literal"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ pub fn os_display_derive(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
} else {
|
||||
|
||||
let variant_name_str = format!("{}", variant_name);
|
||||
let variant_name_str = format!("{variant_name}");
|
||||
quote! { f.write_str(#variant_name_str)?; }
|
||||
};
|
||||
|
||||
|
@ -127,7 +127,7 @@ pub fn os_display_derive(input: TokenStream) -> TokenStream {
|
|||
.unnamed
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, _)| Ident::new(&format!("_{}", i), variant.span()))
|
||||
.map(|(i, _)| Ident::new(&format!("_{i}"), variant.span()))
|
||||
.collect();
|
||||
|
||||
|
||||
|
@ -268,7 +268,7 @@ pub fn os_display_derive(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
},
|
||||
Fields::Unnamed(fields) => {
|
||||
let idents: Vec<Ident> = fields.unnamed.iter().enumerate().map(|(i, _)| Ident::new(&format!("_{}", i), name.span())).collect();
|
||||
let idents: Vec<Ident> = fields.unnamed.iter().enumerate().map(|(i, _)| Ident::new(&format!("_{i}"), name.span())).collect();
|
||||
quote! {
|
||||
let Self(#(#idents),*) = self;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ fn parse_os_display_format_string(
|
|||
}
|
||||
|
||||
let mut placeholder_content = String::new();
|
||||
while let Some(p) = chars.next() {
|
||||
for p in &mut chars {
|
||||
if p == '}' {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue