From 9db94de7faab3976dac9c2e214af8d518bd8995f Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 13 Jun 2023 10:36:22 +0200 Subject: [PATCH 1/2] Allow `used_underscore_binding` for writer and add `must_use` annotation --- src/staticfiles.rs | 1 + src/template.rs | 1 + src/templateexpression.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/staticfiles.rs b/src/staticfiles.rs index 07e832c..5ddc2c3 100644 --- a/src/staticfiles.rs +++ b/src/staticfiles.rs @@ -238,6 +238,7 @@ pub struct StaticFile { #[allow(dead_code)] impl StaticFile { /// Get a single `StaticFile` by name, if it exists. + #[must_use] pub fn get(name: &str) -> Option<&'static Self> { if let Ok(pos) = STATICS.binary_search_by_key(&name, |s| s.name) { Some(STATICS[pos]) diff --git a/src/template.rs b/src/template.rs index d9cef9f..0bde1eb 100644 --- a/src/template.rs +++ b/src/template.rs @@ -41,6 +41,7 @@ impl Template { writeln!( out, "\n\ + #[allow(clippy::used_underscore_binding)]\n\ pub fn {name}<{ta}{ta_sep}W>(_ructe_out_: &mut W{args}) -> io::Result<()>\n\ where W: Write {{\n\ {body}\ diff --git a/src/templateexpression.rs b/src/templateexpression.rs index 2d6213d..b9c3d8e 100644 --- a/src/templateexpression.rs +++ b/src/templateexpression.rs @@ -59,7 +59,7 @@ impl Display for TemplateArgument { } TemplateArgument::Body(ref v) => writeln!( out, - "|mut _ructe_out_| {{\n{}\nOk(())\n}}", + "#[allow(clippy::used_underscore_binding)] |mut _ructe_out_| {{\n{}\nOk(())\n}}", v.iter().map(|b| b.code()).format(""), ), } From bb6c042f1ddef21327bf8d58d1cae7b98d30afd1 Mon Sep 17 00:00:00 2001 From: Rasmus Kaj Date: Sat, 15 Jul 2023 16:10:53 +0200 Subject: [PATCH 2/2] Fix my bad merge. --- src/template.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/template.rs b/src/template.rs index 4d8f136..bd7f143 100644 --- a/src/template.rs +++ b/src/template.rs @@ -41,7 +41,8 @@ impl Template { writeln!( out, "\n\ - pub fn {name}<{ta}{ta_sep}W>(#[allow(unused_mut, clippy::used_underscore_binding)] mut _ructe_out_: W{args}) -> io::Result<()>\n\ + #[allow(clippy::used_underscore_binding)]\n + pub fn {name}<{ta}{ta_sep}W>(#[allow(unused_mut)] mut _ructe_out_: W{args}) -> io::Result<()>\n\ where W: Write {{\n\ {body}\ Ok(())\n\