fastn_resolved/evalexpr/context/predefined/mod.rs
1/// Context with all Rust's constants in `f64::consts` available by default.
2/// Alternatively, specifiy constants with `math_consts_context!(E, PI, TAU, ...)`
3/// Available constants can be found in the [`core::f64::consts module`](https://doc.rust-lang.org/nightly/core/f64/consts/index.html).
4#[macro_export]
5macro_rules! math_consts_context {
6 () => {
7 $fastn_resolved::evalexpr::math_consts_context!(
8 PI,
9 TAU,
10 FRAC_PI_2,
11 FRAC_PI_3,
12 FRAC_PI_4,
13 FRAC_PI_6,
14 FRAC_PI_8,
15 FRAC_1_PI,
16 FRAC_2_PI,
17 FRAC_2_SQRT_PI,
18 SQRT_2,
19 FRAC_1_SQRT_2,
20 E,
21 LOG2_10,
22 LOG2_E,
23 LOG10_2,
24 LOG10_E,
25 LN_2,
26 LN_10
27 )
28 };
29 ($($name:ident),*) => {{
30 use $fastn_resolved::evalexpr::ContextWithMutableVariables;
31 $fastn_resolved::evalexpr::context_map! {
32 $(
33 stringify!($name) => core::f64::consts::$name,
34 )*
35 }
36 }};
37}