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) -> ExactNum
pub fn const_ln10(&mut self) -> ExactNum
Returns the value of the natural logarithm of 10.
Sourcepub fn const_sqrt2(&mut self) -> ExactNum
pub fn const_sqrt2(&mut self) -> ExactNum
Returns √2.
Sourcepub fn const_euler_gamma(&mut self) -> ExactNum
pub fn const_euler_gamma(&mut self) -> ExactNum
Returns the Euler–Mascheroni constant γ.
Sourcepub fn with_rounding_mode<F, R>(&mut self, rm: RoundingMode, f: F) -> R
pub fn with_rounding_mode<F, R>(&mut self, rm: RoundingMode, f: F) -> R
Runs f with rounding mode rm, then restores the previous mode.
If f panics, the previous mode is not restored.
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) -> ExactNum
fn const_ln10(&mut self) -> ExactNum
Source§fn const_sqrt2(&mut self) -> ExactNum
fn const_sqrt2(&mut self) -> ExactNum
Source§fn const_euler_gamma(&mut self) -> ExactNum
fn const_euler_gamma(&mut self) -> ExactNum
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin 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