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;
}
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§

source

fn precision(&self) -> usize

Returns the precision of the context.

source

fn rounding_mode(&self) -> RoundingMode

Returns the rounding mode of the context.

source

fn consts(&mut self) -> &mut Consts

Returns a mutable reference to the constant cache of the context.

source

fn const_pi(&mut self) -> BigFloat

Returns the value of the pi number.

source

fn const_e(&mut self) -> BigFloat

Returns the value of the Euler number.

source

fn const_ln2(&mut self) -> BigFloat

Returns the value of the natural logarithm of 2.

source

fn const_ln10(&mut self) -> BigFloat

Returns the value of the natural logarithm of 10.

Implementations on Foreign Types§

source§

impl Contextable for (usize, RoundingMode, &mut Consts)

source§

fn precision(&self) -> usize

source§

fn rounding_mode(&self) -> RoundingMode

source§

fn consts(&mut self) -> &mut Consts

source§

fn const_pi(&mut self) -> BigFloat

source§

fn const_e(&mut self) -> BigFloat

source§

fn const_ln2(&mut self) -> BigFloat

source§

fn const_ln10(&mut self) -> BigFloat

Implementors§