diff --git a/CHANGELOG.md b/CHANGELOG.md index c12cad1..a059057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## [12.0.1](https://github.com/ISibboI/evalexpr/compare/12.0.0...12.0.1) - 2024-10-25 + +### Fixed + + * Fixed the `math_consts_context!` macro that was broken by in 12.0.0 (#173) + +### Contributors + +My warmhearted thanks goes to: + + * [jeffrey182](https://github.com/jeffrey182) + ## [12.0.0](https://github.com/ISibboI/evalexpr/compare/11.3.1...12.0.0) - 2024-10-17 ### Changed diff --git a/Cargo.lock b/Cargo.lock index d010031..84849b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.160" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b21006cd1874ae9e650973c565615676dc4a274c965bb0a73796dac838ce4f" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "memchr" @@ -83,9 +83,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -181,18 +181,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 707bf7c..ddae561 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ name = "evalexpr" path = "src/lib.rs" [dependencies] -regex = { version = "1.11.0", optional = true } -serde = { version = "1.0.210", features = ["derive"], optional = true } +regex = { version = "1.11.1", optional = true } +serde = { version = "1.0.213", features = ["derive"], optional = true } rand = { version = "0.8.5", optional = true } [features] diff --git a/src/context/mod.rs b/src/context/mod.rs index dea9837..c135b5e 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -419,12 +419,12 @@ macro_rules! context_map { }}; // add an integer value, and chain the eventual error with the ones in the next values ( ($ctx:expr) $k:expr => int $v:expr , $($tt:tt)*) => {{ - $crate::ContextWithMutableVariables::set_value($ctx, $k.into(), Value::from_int($v.into())) + $crate::ContextWithMutableVariables::set_value($ctx, $k.into(), $crate::Value::from_int($v.into())) .and($crate::context_map!(($ctx) $($tt)*)) }}; // add a float value, and chain the eventual error with the ones in the next values ( ($ctx:expr) $k:expr => float $v:expr , $($tt:tt)*) => {{ - $crate::ContextWithMutableVariables::set_value($ctx, $k.into(), Value::from_float($v.into())) + $crate::ContextWithMutableVariables::set_value($ctx, $k.into(), $crate::Value::from_float($v.into())) .and($crate::context_map!(($ctx) $($tt)*)) }}; // add a value, and chain the eventual error with the ones in the next values diff --git a/src/context/predefined/mod.rs b/src/context/predefined/mod.rs index ad8e785..3d15e5d 100644 --- a/src/context/predefined/mod.rs +++ b/src/context/predefined/mod.rs @@ -28,11 +28,28 @@ macro_rules! math_consts_context { ) }; ($($name:ident),*) => {{ - use $crate::ContextWithMutableVariables; $crate::context_map! { $( - stringify!($name) => core::f64::consts::$name, + stringify!($name) => float core::f64::consts::$name, )* } }}; } + +#[cfg(test)] +mod tests { + + #[test] + fn math_consts_context() { + let context: crate::HashMapContext = math_consts_context!().unwrap(); + + { + use crate::{Context, Value}; + + assert_eq!( + context.get_value("PI"), + Some(&Value::Float(core::f64::consts::PI)) + ); + } + } +}