move to new 'predefined' module and add link to f64 docs

This commit is contained in:
Edwin Svensson 2021-05-31 01:13:24 +02:00
parent ec880155c7
commit 9f691206dd
No known key found for this signature in database
GPG Key ID: 7F9EC4DD0C67951F
3 changed files with 38 additions and 38 deletions

View File

@ -163,41 +163,3 @@ macro_rules! context_map {
.map(|_| context) .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,
)*
}
}};
}

View File

@ -501,6 +501,7 @@ mod feature_serde;
mod function; mod function;
mod interface; mod interface;
mod operator; mod operator;
mod predefined;
mod token; mod token;
mod tree; mod tree;
mod value; mod value;

37
src/predefined/mod.rs Normal file
View File

@ -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,
)*
}
}};
}