Skip to main content

Contextable

Trait Contextable 

Source
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§

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.

Source

fn emin(&self) -> i32

Returns the minimum exponent.

Source

fn emax(&self) -> i32

Returns the maximum exponent.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

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

Source§

fn emin(&self) -> i32

Source§

fn emax(&self) -> i32

Source§

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

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

Source§

fn emin(&self) -> i32

Source§

fn emax(&self) -> i32

Implementors§