diff --git a/src/function/builtin.rs b/src/function/builtin.rs index a0600f2..2cee599 100644 --- a/src/function/builtin.rs +++ b/src/function/builtin.rs @@ -24,9 +24,9 @@ macro_rules! simple_math { } fn float_is(func: fn(f64) -> bool) -> Option { - Some(Function::new(move |argument| + Some(Function::new(move |argument| { Ok(func(argument.as_number()?).into()) - )) + })) } macro_rules! int_function { @@ -87,7 +87,7 @@ pub fn builtin_function(identifier: &str) -> Option { "math::is_infinite" => float_is(f64::is_infinite), "math::is_normal" => float_is(f64::is_normal), // Other - "typeof" => Some(Function::new(move |argument| + "typeof" => Some(Function::new(move |argument| { Ok(match argument { Value::String(_) => "string", Value::Float(_) => "float", @@ -95,8 +95,9 @@ pub fn builtin_function(identifier: &str) -> Option { Value::Boolean(_) => "boolean", Value::Tuple(_) => "tuple", Value::Empty => "empty", - }.into()) - )), + } + .into()) + })), "min" => Some(Function::new(|argument| { let arguments = argument.as_tuple()?; let mut min_int = IntType::max_value(); diff --git a/tests/integration.rs b/tests/integration.rs index 17e72e6..e028e1a 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -367,7 +367,10 @@ fn test_builtin_functions() { assert_eq!(eval("math::is_finite(1.0/0.0)"), Ok(Value::Boolean(false))); assert_eq!(eval("math::is_finite(0.0/0.0)"), Ok(Value::Boolean(false))); assert_eq!(eval("math::is_finite(0.0)"), Ok(Value::Boolean(true))); - assert_eq!(eval("math::is_infinite(0.0/0.0)"), Ok(Value::Boolean(false))); + assert_eq!( + eval("math::is_infinite(0.0/0.0)"), + Ok(Value::Boolean(false)) + ); assert_eq!(eval("math::is_infinite(1.0/0.0)"), Ok(Value::Boolean(true))); assert_eq!(eval("math::is_normal(1.0/0.0)"), Ok(Value::Boolean(false))); assert_eq!(eval("math::is_normal(0)"), Ok(Value::Boolean(false))); @@ -449,9 +452,12 @@ fn test_errors() { }) ); assert_eq!(eval("!(()true)"), Err(EvalexprError::AppendedToLeafNode)); - assert_eq!(eval("math::is_nan(\"xxx\")"), Err(EvalexprError::ExpectedNumber { - actual: Value::String("xxx".to_string()) - })); + assert_eq!( + eval("math::is_nan(\"xxx\")"), + Err(EvalexprError::ExpectedNumber { + actual: Value::String("xxx".to_string()) + }) + ); } #[test]