Use implicit format-args captures where applicable (#1709)

This commit is contained in:
Jonas Platte
2023-01-20 12:04:49 +01:00
committed by GitHub
parent b07918b213
commit 7ecf8bd6cf
16 changed files with 42 additions and 46 deletions
+4 -4
View File
@@ -20,7 +20,7 @@ where
if out.is_some() {
let kw_name = std::any::type_name::<K>().split("::").last().unwrap();
let msg = format!("`{}` specified more than once", kw_name);
let msg = format!("`{kw_name}` specified more than once");
return Err(syn::Error::new_spanned(kw, msg));
}
@@ -43,7 +43,7 @@ where
if out.is_some() {
let kw_name = std::any::type_name::<K>().split("::").last().unwrap();
let msg = format!("`{}` specified more than once", kw_name);
let msg = format!("`{kw_name}` specified more than once");
return Err(syn::Error::new_spanned(kw, msg));
}
@@ -74,7 +74,7 @@ where
if let Some((kw, inner)) = b {
if a.is_some() {
let kw_name = std::any::type_name::<K>().split("::").last().unwrap();
let msg = format!("`{}` specified more than once", kw_name);
let msg = format!("`{kw_name}` specified more than once");
return Err(syn::Error::new_spanned(kw, msg));
}
*a = Some((kw, inner));
@@ -89,7 +89,7 @@ where
if let Some(kw) = b {
if a.is_some() {
let kw_name = std::any::type_name::<K>().split("::").last().unwrap();
let msg = format!("`{}` specified more than once", kw_name);
let msg = format!("`{kw_name}` specified more than once");
return Err(syn::Error::new_spanned(kw, msg));
}
*a = Some(kw);
+1 -2
View File
@@ -111,9 +111,8 @@ fn check_extractor_count(item_fn: &ItemFn) -> Option<TokenStream> {
None
} else {
let error_message = format!(
"Handlers cannot take more than {} arguments. \
"Handlers cannot take more than {max_extractors} arguments. \
Use `(a, b): (ExtractorA, ExtractorA)` to further nest extractors",
max_extractors,
);
let error = syn::Error::new_spanned(&item_fn.sig.inputs, error_message).to_compile_error();
Some(error)
+4 -4
View File
@@ -665,7 +665,7 @@ where
Ok(tokens) => {
let tokens = (quote! { #tokens }).into();
if std::env::var_os("AXUM_MACROS_DEBUG").is_some() {
eprintln!("{}", tokens);
eprintln!("{tokens}");
}
tokens
}
@@ -722,7 +722,7 @@ fn run_ui_tests(directory: &str) {
path = path_without_prefix.to_owned();
}
if !path.contains(&format!("/{}/", directory)) {
if !path.contains(&format!("/{directory}/")) {
return;
}
@@ -734,8 +734,8 @@ fn run_ui_tests(directory: &str) {
panic!()
}
} else {
t.compile_fail(format!("tests/{}/fail/*.rs", directory));
t.pass(format!("tests/{}/pass/*.rs", directory));
t.compile_fail(format!("tests/{directory}/fail/*.rs"));
t.pass(format!("tests/{directory}/pass/*.rs"));
}
}
+3 -3
View File
@@ -267,9 +267,9 @@ fn expand_unnamed_fields(
fn simple_pluralize(count: usize, word: &str) -> String {
if count == 1 {
format!("{} {}", count, word)
format!("{count} {word}")
} else {
format!("{} {}s", count, word)
format!("{count} {word}s")
}
}
@@ -354,7 +354,7 @@ fn format_str_from_path(segments: &[Segment]) -> String {
segments
.iter()
.map(|segment| match segment {
Segment::Capture(capture, _) => format!("{{{}}}", capture),
Segment::Capture(capture, _) => format!("{{{capture}}}"),
Segment::Static(segment) => segment.to_owned(),
})
.collect::<Vec<_>>()