From 604ddf7bd311acaccd02306bdbcddd1817cc730a Mon Sep 17 00:00:00 2001 From: Luis Moreno Date: Mon, 9 Dec 2024 09:37:55 -0400 Subject: [PATCH] chore: fix clippy --- src/expression_evaluator.rs | 16 ++++++++-------- src/expression_parser.rs | 2 +- src/renderer.rs | 10 +++++----- src/statement/mod.rs | 12 ++++++------ src/template.rs | 2 +- src/value/from.rs | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/expression_evaluator.rs b/src/expression_evaluator.rs index 47a2f7f..af2a695 100644 --- a/src/expression_evaluator.rs +++ b/src/expression_evaluator.rs @@ -49,7 +49,7 @@ impl<'a> TupleExpression<'a> { self.expressions.push(expression) } } -impl<'a> Evaluate for TupleExpression<'a> { +impl Evaluate for TupleExpression<'_> { fn evaluate(&self, values: Context<'_>) -> Result { let tuple: ValuesList = self .expressions @@ -72,7 +72,7 @@ impl<'a> DictionaryExpression<'a> { self.elems.insert(key, value); } } -impl<'a> Evaluate for DictionaryExpression<'a> { +impl Evaluate for DictionaryExpression<'_> { fn evaluate(&self, values: Context<'_>) -> Result { let mut dict = ValuesMap::new(); for (key, expression) in self.elems.iter() { @@ -92,7 +92,7 @@ impl<'a> FilteredExpression<'a> { } } -impl<'a> Evaluate for FilteredExpression<'a> { +impl Evaluate for FilteredExpression<'_> { fn evaluate(&self, values: Context<'_>) -> Result { let result = self.expression.evaluate(values.clone()); let base_value = match result { @@ -136,7 +136,7 @@ impl<'a> SubscriptExpression<'a> { self.subscript_expression.push(subscript); } } -impl<'a> Evaluate for SubscriptExpression<'a> { +impl Evaluate for SubscriptExpression<'_> { fn evaluate(&self, values: Context<'_>) -> Result { let mut cur = self.expression.evaluate(values.clone())?; for idx in &self.subscript_expression { @@ -147,7 +147,7 @@ impl<'a> Evaluate for SubscriptExpression<'a> { Ok(cur) } } -impl<'a> Evaluate for Expression<'a> { +impl Evaluate for Expression<'_> { fn evaluate(&self, values: Context<'_>) -> Result { let result = match &self { Expression::Constant(value) => value.clone(), @@ -179,7 +179,7 @@ pub struct FullExpressionEvaluator<'a> { expression: Option>, } -impl<'a> Render for FullExpressionEvaluator<'a> { +impl Render for FullExpressionEvaluator<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { let value = self.evaluate(params)?; if let Err(err) = out.write(value.to_string().as_bytes()) { @@ -196,7 +196,7 @@ impl<'a> FullExpressionEvaluator<'a> { } } -impl<'a> Evaluate for FullExpressionEvaluator<'a> { +impl Evaluate for FullExpressionEvaluator<'_> { fn evaluate(&self, values: Context<'_>) -> Result { let result = match &self.expression { Some(expression) => expression.evaluate(values)?, @@ -212,7 +212,7 @@ pub struct CallParams<'a> { pub pos_params: Vec>, } -impl<'a> CallParams<'a> { +impl CallParams<'_> { pub fn parse<'b>( &self, param_names: Vec<&'b str>, diff --git a/src/expression_parser.rs b/src/expression_parser.rs index 03ccf3f..8f677e9 100644 --- a/src/expression_parser.rs +++ b/src/expression_parser.rs @@ -15,7 +15,7 @@ use logos::{Lexer, Logos}; pub struct ExpressionParser {} impl ExpressionParser { - pub fn parse<'a>(text: &'a str) -> Result> { + pub fn parse<'a>(text: &'a str) -> Result> { let lexer: Lexer<'_, Token<'a>> = Token::lexer(text); let mut lexer = PeekableLexer::new(lexer); diff --git a/src/renderer.rs b/src/renderer.rs index f198900..0982778 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -24,13 +24,13 @@ impl<'a> ComposedRenderer<'a> { } } -impl<'a> Default for ComposedRenderer<'a> { +impl Default for ComposedRenderer<'_> { fn default() -> Self { Self::new() } } -impl<'a> Render for ComposedRenderer<'a> { +impl Render for ComposedRenderer<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { for r in self.renderers.read().unwrap().iter() { r.render(out, params.clone())?; @@ -39,7 +39,7 @@ impl<'a> Render for ComposedRenderer<'a> { } } -impl<'a> fmt::Debug for ComposedRenderer<'a> { +impl fmt::Debug for ComposedRenderer<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ComposedRenderer") } @@ -61,7 +61,7 @@ impl<'a> RawTextRenderer<'a> { } } -impl<'a> Render for RawTextRenderer<'a> { +impl Render for RawTextRenderer<'_> { fn render(&self, out: &mut dyn Write, _params: Context<'_>) -> Result<()> { if let Err(err) = out.write(self.content.as_bytes()) { Err(Error::Io(err)) @@ -75,7 +75,7 @@ pub struct ExpressionRenderer<'a> { expression: FullExpressionEvaluator<'a>, } -impl<'a> Render for ExpressionRenderer<'a> { +impl Render for ExpressionRenderer<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { self.expression.render(out, params) } diff --git a/src/statement/mod.rs b/src/statement/mod.rs index 3bc021d..e5c1c8f 100644 --- a/src/statement/mod.rs +++ b/src/statement/mod.rs @@ -31,7 +31,7 @@ impl<'a> IfStatement<'a> { self.else_branches.push(branch); } } -impl<'a> Render for IfStatement<'a> { +impl Render for IfStatement<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { let value = self.expression.evaluate(params.clone())?; if let Value::Boolean(true) = value { @@ -77,7 +77,7 @@ impl<'a> ElseStatement<'a> { } } } -impl<'a> Render for ElseStatement<'a> { +impl Render for ElseStatement<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { self.body.as_ref().unwrap().render(out, params) } @@ -98,7 +98,7 @@ impl<'a> WithStatement<'a> { self.body = Some(with_body); } } -impl<'a> Render for WithStatement<'a> { +impl Render for WithStatement<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { let mut inner_values = params.clone(); let scope = inner_values.enter_scope(); @@ -166,7 +166,7 @@ impl<'a> ForStatement<'a> { Ok(()) } } -impl<'a> Render for ForStatement<'a> { +impl Render for ForStatement<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { let loop_value = self.value.evaluate(params.clone())?; self.render_loop(loop_value, out, params, 0)?; @@ -192,7 +192,7 @@ impl<'a> IncludeStatement<'a> { } } } -impl<'a> Render for IncludeStatement<'a> { +impl Render for IncludeStatement<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { let template_env = params.get_renderer_callback(); let name = self.expr_name.evaluate(params.clone())?.to_string(); @@ -243,7 +243,7 @@ impl<'a> Statement<'a> { } } } -impl<'a> Render for Statement<'a> { +impl Render for Statement<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { match self { Statement::If(statement) => statement.render(out, params), diff --git a/src/template.rs b/src/template.rs index de2ff55..b4f5cf5 100644 --- a/src/template.rs +++ b/src/template.rs @@ -68,7 +68,7 @@ impl<'a> Template<'a> { } } -impl<'a> Render for Template<'a> { +impl Render for Template<'_> { fn render(&self, out: &mut dyn Write, params: Context<'_>) -> Result<()> { if let Some(ref renderer) = self.renderer { let result = renderer.render(out, params); diff --git a/src/value/from.rs b/src/value/from.rs index aab459d..584fdcb 100644 --- a/src/value/from.rs +++ b/src/value/from.rs @@ -80,7 +80,7 @@ impl From for Value { } } -impl<'a> From<&'a str> for Value { +impl From<&str> for Value { fn from(f: &str) -> Self { Value::String(f.to_string()) }