From f7d6ee9d7e90486ca9f8aa3dc7d61dece9c903f9 Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 16 Feb 2024 09:05:00 -0500 Subject: [PATCH] minor cleanup --- Cargo.toml | 4 ++-- src/helper.rs | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index da5ff03..6c9c210 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quickmaths" -version = "0.2.2" +version = "0.2.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,5 +15,5 @@ codegen-units = 1 debug = false lto = true panic = "abort" -strip = "debuginfo" +strip = "symbols" diff --git a/src/helper.rs b/src/helper.rs index d13138c..02c57de 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -6,8 +6,11 @@ use evalexpr::{ use crate::util; +pub type EvalResult = Result; + + // Mathematics -pub fn fix(arg: &Value) -> Result { +pub fn fix(arg: &Value) -> EvalResult { let args = arg.as_tuple()?; let count = args.len(); @@ -23,7 +26,7 @@ pub fn fix(arg: &Value) -> Result { return Ok(output.into()); } -pub fn logarithm(arg: &Value) -> Result { +pub fn logarithm(arg: &Value) -> EvalResult { let arguments: Vec; let count: usize; if arg.is_tuple() { @@ -66,7 +69,7 @@ pub fn logarithm(arg: &Value) -> Result { return Ok(output); } -pub fn square_root(arg: &Value) -> Result { +pub fn square_root(arg: &Value) -> EvalResult { if !arg.is_number() { return Err(EvalexprError::CustomMessage("Expected a number.".to_string())); } @@ -74,8 +77,9 @@ pub fn square_root(arg: &Value) -> Result { return Ok(value.sqrt().into()); } + // Data Science -pub fn average(arg: &Value) -> Result { +pub fn average(arg: &Value) -> EvalResult { let arguments = arg.as_tuple()?; let count = arguments.len() as i64; let mut is_float = false; @@ -115,7 +119,7 @@ pub fn average(arg: &Value) -> Result { } // Radix conversion -pub fn binary(arg: &Value) -> Result { +pub fn binary(arg: &Value) -> EvalResult { if !arg.is_string() { let num = arg.as_int()?; let fmt = format!("0b{:b}", num); @@ -124,7 +128,7 @@ pub fn binary(arg: &Value) -> Result { util::parse_radix("0b", 2, arg) } -pub fn hexadecimal(arg: &Value) -> Result { +pub fn hexadecimal(arg: &Value) -> EvalResult { if !arg.is_string() { let num = arg.as_int()?; let fmt = format!("0x{:X}", num); @@ -133,7 +137,7 @@ pub fn hexadecimal(arg: &Value) -> Result { util::parse_radix("0x", 16, arg) } -pub fn octal(arg: &Value) -> Result { +pub fn octal(arg: &Value) -> EvalResult { if !arg.is_string() { let num = arg.as_int()?; let fmt = format!("{:#o}", num);