From 9f691206dd5be9558bcc4a265629f9448beb333a Mon Sep 17 00:00:00 2001 From: Edwin Svensson Date: Mon, 31 May 2021 01:13:24 +0200 Subject: [PATCH] move to new 'predefined' module and add link to f64 docs --- src/context/mod.rs | 38 -------------------------------------- src/lib.rs | 1 + src/predefined/mod.rs | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 src/predefined/mod.rs diff --git a/src/context/mod.rs b/src/context/mod.rs index 94fe055..ef27b6f 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -163,41 +163,3 @@ macro_rules! context_map { .map(|_| context) }}; } - -/// Context with all f64::consts available by default. -/// Alternatively, specifiy constants with math_consts_context!(E, PI, TAU, ...) -/// Available constants can be found in the core::f64::consts module. -#[macro_export] -macro_rules! math_consts_context { - () => { - $crate::math_consts_context!( - PI, - TAU, - FRAC_PI_2, - FRAC_PI_3, - FRAC_PI_4, - FRAC_PI_6, - FRAC_PI_8, - FRAC_1_PI, - FRAC_2_PI, - FRAC_2_SQRT_PI, - SQRT_2, - FRAC_1_SQRT_2, - E, - LOG2_10, - LOG2_E, - LOG10_2, - LOG10_E, - LN_2, - LN_10 - ) - }; - ($($name:ident),*) => {{ - use $crate::ContextWithMutableVariables; - $crate::context_map! { - $( - stringify!($name) => core::f64::consts::$name, - )* - } - }}; -} diff --git a/src/lib.rs b/src/lib.rs index d20d49b..7e16ec9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -501,6 +501,7 @@ mod feature_serde; mod function; mod interface; mod operator; +mod predefined; mod token; mod tree; mod value; diff --git a/src/predefined/mod.rs b/src/predefined/mod.rs new file mode 100644 index 0000000..05ca62d --- /dev/null +++ b/src/predefined/mod.rs @@ -0,0 +1,37 @@ +/// Context with all f64::consts available by default. +/// Alternatively, specifiy constants with `math_consts_context!(E, PI, TAU, ...)` +/// Available constants can be found in the [`core::f64::consts module`](https://doc.rust-lang.org/nightly/core/f64/consts/index.html). +#[macro_export] +macro_rules! math_consts_context { + () => { + $crate::math_consts_context!( + PI, + TAU, + FRAC_PI_2, + FRAC_PI_3, + FRAC_PI_4, + FRAC_PI_6, + FRAC_PI_8, + FRAC_1_PI, + FRAC_2_PI, + FRAC_2_SQRT_PI, + SQRT_2, + FRAC_1_SQRT_2, + E, + LOG2_10, + LOG2_E, + LOG10_2, + LOG10_E, + LN_2, + LN_10 + ) + }; + ($($name:ident),*) => {{ + use $crate::ContextWithMutableVariables; + $crate::context_map! { + $( + stringify!($name) => core::f64::consts::$name, + )* + } + }}; +}