1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
use super::api::*; use super::rel::*; pub struct SqrtFunction { } impl ScalarFunction for SqrtFunction { fn execute(&self, args: Vec<Value>) -> Result<Value,Box<String>> { match args[0] { Value::Double(d) => Ok(Value::Double(d.sqrt())), Value::UnsignedLong(l) => Ok(Value::Double((l as f64).sqrt())), _ => Err(Box::new("Unsupported arg type for sqrt".to_string())) } } }