Fixed warnings and removed unused dependencies.

This commit is contained in:
Sebastian Schmidt 2019-03-15 17:21:34 +02:00
parent 045313f076
commit 3975a17f0b
4 changed files with 11 additions and 16 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "evalexpr" name = "evalexpr"
version = "0.4.4" version = "0.5.0"
description = "Expression evaluator" description = "Expression evaluator"
keywords = ["expression", "evaluate", "evaluator", "expr", "template"] keywords = ["expression", "evaluate", "evaluator", "expr", "template"]
authors = ["fengcen <fengcen.love@gmail.com>", "isibboi <isibboi@gmail.com>"] authors = ["fengcen <fengcen.love@gmail.com>", "isibboi <isibboi@gmail.com>"]
@ -15,9 +15,5 @@ name = "evalexpr"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
serde = ">= 0.9, < 2"
serde_json = ">= 0.9, < 2"
quick-error = "^1.1"
[features] [features]
unstable = []

View File

@ -7,7 +7,7 @@ pub trait Configuration {
pub struct EmptyConfiguration; pub struct EmptyConfiguration;
impl Configuration for EmptyConfiguration { impl Configuration for EmptyConfiguration {
fn get_value(&self, identifier: &str) -> Result<Value, Error> { fn get_value(&self, _identifier: &str) -> Result<Value, Error> {
Err(Error::IdentifierNotFound) Err(Error::IdentifierNotFound)
} }
} }

View File

@ -55,7 +55,7 @@ impl Operator for RootNode {
1 1
} }
fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result<Value, Error> { fn eval(&self, _arguments: &[Value], _configuration: &Configuration) -> Result<Value, Error> {
Err(Error::EvaluatedRootNode) Err(Error::EvaluatedRootNode)
} }
} }
@ -69,7 +69,7 @@ impl Operator for Add {
2 2
} }
fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result<Value, Error> { fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result<Value, Error> {
expect_argument_amount(arguments.len(), 2)?; expect_argument_amount(arguments.len(), 2)?;
let a = expect_number(&arguments[0])?; let a = expect_number(&arguments[0])?;
let b = expect_number(&arguments[1])?; let b = expect_number(&arguments[1])?;
@ -87,7 +87,7 @@ impl Operator for Sub {
2 2
} }
fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result<Value, Error> { fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result<Value, Error> {
expect_argument_amount(arguments.len(), 2)?; expect_argument_amount(arguments.len(), 2)?;
let a = expect_number(&arguments[0])?; let a = expect_number(&arguments[0])?;
let b = expect_number(&arguments[1])?; let b = expect_number(&arguments[1])?;
@ -105,7 +105,7 @@ impl Operator for Mul {
2 2
} }
fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result<Value, Error> { fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result<Value, Error> {
expect_argument_amount(arguments.len(), 2)?; expect_argument_amount(arguments.len(), 2)?;
let a = expect_number(&arguments[0])?; let a = expect_number(&arguments[0])?;
let b = expect_number(&arguments[1])?; let b = expect_number(&arguments[1])?;
@ -123,7 +123,7 @@ impl Operator for Div {
2 2
} }
fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result<Value, Error> { fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result<Value, Error> {
expect_argument_amount(arguments.len(), 2)?; expect_argument_amount(arguments.len(), 2)?;
let a = expect_number(&arguments[0])?; let a = expect_number(&arguments[0])?;
let b = expect_number(&arguments[1])?; let b = expect_number(&arguments[1])?;
@ -141,7 +141,7 @@ impl Operator for Const {
0 0
} }
fn eval(&self, arguments: &[Value], configuration: &Configuration) -> Result<Value, Error> { fn eval(&self, arguments: &[Value], _configuration: &Configuration) -> Result<Value, Error> {
expect_argument_amount(arguments.len(), 0)?; expect_argument_amount(arguments.len(), 0)?;
Ok(self.value.clone()) Ok(self.value.clone())

View File

@ -1,5 +1,4 @@
use crate::{configuration::Configuration, error::Error, operator::*, value::Value}; use crate::{configuration::Configuration, error::Error, operator::*, value::Value};
use std::mem;
use token::Token; use token::Token;
pub struct Node { pub struct Node {
@ -42,7 +41,7 @@ impl Node {
self.children().len() == self.operator().argument_amount() self.children().len() == self.operator().argument_amount()
} }
fn insert_back_prioritized(&mut self, mut operator: Box<dyn Operator>) -> Result<(), Error> { fn insert_back_prioritized(&mut self, operator: Box<dyn Operator>) -> Result<(), Error> {
if self.operator().precedence() < operator.precedence() { if self.operator().precedence() < operator.precedence() {
if self.operator().is_leaf() { if self.operator().is_leaf() {
Err(Error::AppendedToLeafNode) Err(Error::AppendedToLeafNode)
@ -54,7 +53,7 @@ impl Node {
.unwrap() .unwrap()
.insert_back_prioritized(operator) .insert_back_prioritized(operator)
} else { } else {
let mut new_node = Node::new(operator); let new_node = Node::new(operator);
let last_child = self.children.pop().unwrap(); let last_child = self.children.pop().unwrap();
self.children.push(new_node); self.children.push(new_node);
let new_node = self.children.last_mut().unwrap(); let new_node = self.children.last_mut().unwrap();
@ -92,7 +91,7 @@ pub fn tokens_to_operator_tree(tokens: Vec<Token>) -> Result<Node, Error> {
}; };
if let Some(operator) = operator { if let Some(operator) = operator {
root.insert_back_prioritized(operator); root.insert_back_prioritized(operator)?;
} }
} }