pub struct Context { /* private fields */ }
Expand description
Context contains parameters, like rounding mode and precision, as well as constant values, and is used with expr!
macro.
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(
p: usize,
rm: RoundingMode,
cc: Consts,
emin: i32,
emax: i32,
) -> Context
pub fn new( p: usize, rm: RoundingMode, cc: Consts, emin: i32, emax: i32, ) -> Context
Create a new context.
The value of emin
will be clamped to a range between EXPONENT_MIN and 0.
The value of emax
will be clamped to a range between 0 and EXPONENT_MAX.
Sourcepub fn to_raw_parts(self) -> (usize, RoundingMode, Consts, i32, i32)
pub fn to_raw_parts(self) -> (usize, RoundingMode, Consts, i32, i32)
Destructures the context and returns its parts: target precision, rounding mode, constant cache, minimum exponent, maximum exponent.
Sourcepub fn set_precision(&mut self, p: usize)
pub fn set_precision(&mut self, p: usize)
Sets the precision of the context.
Sourcepub fn set_rounding_mode(&mut self, rm: RoundingMode)
pub fn set_rounding_mode(&mut self, rm: RoundingMode)
Sets the rounding mode of the context.
Sourcepub fn set_consts(&mut self, cc: Consts)
pub fn set_consts(&mut self, cc: Consts)
Sets the constant cache of the context.
Sourcepub fn set_emin(&mut self, emin: i32)
pub fn set_emin(&mut self, emin: i32)
Sets the minimum exponent.
The value of emin
will be clamped to a range between EXPONENT_MIN and 0.
Sourcepub fn set_emax(&mut self, emax: i32)
pub fn set_emax(&mut self, emax: i32)
Sets the maximum exponent.
The value of emax
will be clamped to a range between 0 and EXPONENT_MAX.
Sourcepub fn rounding_mode(&self) -> RoundingMode
pub fn rounding_mode(&self) -> RoundingMode
Returns the rounding mode of the context.
Sourcepub fn consts(&mut self) -> &mut Consts
pub fn consts(&mut self) -> &mut Consts
Returns a mutable reference to the constant cache of the context.
Sourcepub fn const_ln10(&mut self) -> BigFloat
pub fn const_ln10(&mut self) -> BigFloat
Returns the value of the natural logarithm of 10.
Trait Implementations§
Source§impl Contextable for Context
impl Contextable for Context
Source§fn rounding_mode(&self) -> RoundingMode
fn rounding_mode(&self) -> RoundingMode
Source§fn consts(&mut self) -> &mut Consts
fn consts(&mut self) -> &mut Consts
Source§fn const_ln10(&mut self) -> BigFloat
fn const_ln10(&mut self) -> BigFloat
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more