evalexpr
evalexpr copied to clipboard
Add features: `decimal_support`/`empty_is_null`
This PR adds two features decimal_support and empty_is_null.
Feature decimal_support #115
The decimal_support feature enables support for Decimal float type calculation using the rust_decimal library.
Note that due to limitations in the rust_decimal library, certain math calculations are not supported.,the following built-in functions are not available:
loglog2exp2acoscoshacoshasinsinhasinhatantanhatanhatan2cbrthypotis_nanis_finiteis_infiniteis_normal
Feature empty_is_null
The empty_is_null feature ensures that calculations involving the Empty type behave similarly to Null, following the SQL Null standard (https://en.wikipedia.org/wiki/Null_(SQL)).
use evalexpr::*;
assert_eq!(eval("1 + 2 + ()"), Ok(Value::Empty)));
assert_eq!(eval("() * 2"), Ok(Value::Empty)));
assert_eq!(eval("2 / () "), Ok(Value::Empty)));
assert_eq!(eval("true && () "), Ok(Value::Empty)));
assert_eq!(eval("true || ()"), Ok(Value::Boolean(true))));
assert_eq!(eval("false || ()"), Ok(Value::Empty)));
Thank you for the pull request. I agree that supporting rust_decimal would be great for this crate! However I have doubts about the maintainability of the changes made in this pull request, as they are introducing a vast number of conditional compilation. I have before planned to support custom numeric types in a different way via generics, but did not have time for that yet. Merging this pull request would not make it easier to make the numeric types generic, hence I am sorry but I have to reject this pull request.