diff options
Diffstat (limited to 'src/commonsense.rs')
| -rw-r--r-- | src/commonsense.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/commonsense.rs b/src/commonsense.rs index df688fb..4570109 100644 --- a/src/commonsense.rs +++ b/src/commonsense.rs @@ -40,7 +40,8 @@ pub fn tan(a: Complex) -> Complex { macro_rules! commonsense_functions { {$($x:expr => $y:expr), *} => { { - let mut h : HashMap<String, Box<dyn Function>> = HashMap::new(); + use std::sync::Arc; + let mut h : HashMap<String, Arc<dyn Function>> = HashMap::new(); h.extend(functions!{ "sqrt" => &crate::commonsense::sqrt, "sin" => &crate::commonsense::sin, @@ -48,7 +49,7 @@ macro_rules! commonsense_functions { "tan" => &crate::commonsense::tan }); $( - h.insert($x.to_string(), Box::new($y)); + h.insert($x.to_string(), Arc::new($y)); )* h } @@ -59,11 +60,11 @@ macro_rules! commonsense_functions { macro_rules! commonsense_operations { {$($x:expr => $y:expr), *} => { vec![ - Operation::new('+', Box::new(&crate::commonsense::add)), - Operation::new('-', Box::new(&crate::commonsense::sub)), - Operation::new('*', Box::new(&crate::commonsense::mul)), - Operation::new('/', Box::new(&crate::commonsense::div)), - Operation::new('^', Box::new(&crate::commonsense::pow)) + Operation::new('+', crate::commonsense::add), + Operation::new('-', crate::commonsense::sub), + Operation::new('*', crate::commonsense::mul), + Operation::new('/', crate::commonsense::div), + Operation::new('^', crate::commonsense::pow) $( Operation::new($x, Box::new($y)), )*] |