pub trait Contextable {
// Required methods
fn precision(&self) -> usize;
fn rounding_mode(&self) -> RoundingMode;
fn consts(&mut self) -> &mut Consts;
fn const_pi(&mut self) -> BigFloat;
fn const_e(&mut self) -> BigFloat;
fn const_ln2(&mut self) -> BigFloat;
fn const_ln10(&mut self) -> BigFloat;
fn emin(&self) -> i32;
fn emax(&self) -> i32;
}
Expand description
Represents a type that can be used as context in expr!
macro.
§Examples
let p = 123;
let rm = RoundingMode::Down;
let mut cc = Consts::new().expect("Constants cache allocated");
let pi = cc.pi(p, rm);
// Make context out of tuple.
let mut ctx = (p, rm, &mut cc);
assert_eq!(p, ctx.precision());
assert_eq!(rm, ctx.rounding_mode());
assert_eq!(pi, ctx.const_pi());
Required Methods§
Sourcefn rounding_mode(&self) -> RoundingMode
fn rounding_mode(&self) -> RoundingMode
Returns the rounding mode of the context.
Sourcefn consts(&mut self) -> &mut Consts
fn consts(&mut self) -> &mut Consts
Returns a mutable reference to the constant cache of the context.
Sourcefn const_ln10(&mut self) -> BigFloat
fn const_ln10(&mut self) -> BigFloat
Returns the value of the natural logarithm of 10.