From 3975a17f0b538fe2a755243bbd2036061fa9cca1 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 15 Mar 2019 17:21:34 +0200 Subject: [PATCH] Fixed warnings and removed unused dependencies. --- Cargo.toml | 6 +----- src/configuration/mod.rs | 2 +- src/operator/mod.rs | 12 ++++++------ src/tree/mod.rs | 7 +++---- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index afeed4e..9883f99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "evalexpr" -version = "0.4.4" +version = "0.5.0" description = "Expression evaluator" keywords = ["expression", "evaluate", "evaluator", "expr", "template"] authors = ["fengcen ", "isibboi "] @@ -15,9 +15,5 @@ name = "evalexpr" path = "src/lib.rs" [dependencies] -serde = ">= 0.9, < 2" -serde_json = ">= 0.9, < 2" -quick-error = "^1.1" [features] -unstable = [] diff --git a/src/configuration/mod.rs b/src/configuration/mod.rs index 730a413..ef20033 100644 --- a/src/configuration/mod.rs +++ b/src/configuration/mod.rs @@ -7,7 +7,7 @@ pub trait Configuration { pub struct EmptyConfiguration; impl Configuration for EmptyConfiguration { - fn get_value(&self, identifier: &str) -> Result { + fn get_value(&self, _identifier: &str) -> Result { Err(Error::IdentifierNotFound) } } diff --git a/src/operator/mod.rs b/src/operator/mod.rs index cf5e872..57fbfd3 100644 --- a/src/operator/mod.rs +++ b/src/operator/mod.rs @@ -55,7 +55,7 @@ impl Operator for RootNode { 1 } - fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result { + fn eval(&self, _arguments: &[Value], _configuration: &Configuration) -> Result { Err(Error::EvaluatedRootNode) } } @@ -69,7 +69,7 @@ impl Operator for Add { 2 } - fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result { + fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result { expect_argument_amount(arguments.len(), 2)?; let a = expect_number(&arguments[0])?; let b = expect_number(&arguments[1])?; @@ -87,7 +87,7 @@ impl Operator for Sub { 2 } - fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result { + fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result { expect_argument_amount(arguments.len(), 2)?; let a = expect_number(&arguments[0])?; let b = expect_number(&arguments[1])?; @@ -105,7 +105,7 @@ impl Operator for Mul { 2 } - fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result { + fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result { expect_argument_amount(arguments.len(), 2)?; let a = expect_number(&arguments[0])?; let b = expect_number(&arguments[1])?; @@ -123,7 +123,7 @@ impl Operator for Div { 2 } - fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result { + fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result { expect_argument_amount(arguments.len(), 2)?; let a = expect_number(&arguments[0])?; let b = expect_number(&arguments[1])?; @@ -141,7 +141,7 @@ impl Operator for Const { 0 } - fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result { + fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result { expect_argument_amount(arguments.len(), 0)?; Ok(self.value.clone()) diff --git a/src/tree/mod.rs b/src/tree/mod.rs index 335ca90..b379f30 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -1,5 +1,4 @@ use crate::{configuration::Configuration, error::Error, operator::*, value::Value}; -use std::mem; use token::Token; pub struct Node { @@ -42,7 +41,7 @@ impl Node { self.children().len() == self.operator().argument_amount() } - fn insert_back_prioritized(&mut self, mut operator: Box) -> Result<(), Error> { + fn insert_back_prioritized(&mut self, operator: Box) -> Result<(), Error> { if self.operator().precedence() < operator.precedence() { if self.operator().is_leaf() { Err(Error::AppendedToLeafNode) @@ -54,7 +53,7 @@ impl Node { .unwrap() .insert_back_prioritized(operator) } else { - let mut new_node = Node::new(operator); + let new_node = Node::new(operator); let last_child = self.children.pop().unwrap(); self.children.push(new_node); let new_node = self.children.last_mut().unwrap(); @@ -92,7 +91,7 @@ pub fn tokens_to_operator_tree(tokens: Vec) -> Result { }; if let Some(operator) = operator { - root.insert_back_prioritized(operator); + root.insert_back_prioritized(operator)?; } }