Struct astro_float::ctx::Context

source ·
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

source

pub fn new(p: usize, rm: RoundingMode, cc: Consts) -> Context

Create a new context.

source

pub fn to_raw_parts(self) -> (usize, RoundingMode, Consts)

Destructures the context and returns its parts.

source

pub fn set_precision(&mut self, p: usize)

Sets the precision of the context.

source

pub fn set_rounding_mode(&mut self, rm: RoundingMode)

Sets the rounding mode of the context.

source

pub fn set_consts(&mut self, cc: Consts)

Sets the constant cache of the context.

source

pub fn precision(&self) -> usize

Returns the precision of the context.

source

pub fn rounding_mode(&self) -> RoundingMode

Returns the rounding mode of the context.

source

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

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

source

pub fn const_pi(&mut self) -> BigFloat

Returns the value of the pi number.

source

pub fn const_e(&mut self) -> BigFloat

Returns the value of the Euler number.

source

pub fn const_ln2(&mut self) -> BigFloat

Returns the value of the natural logarithm of 2.

source

pub fn const_ln10(&mut self) -> BigFloat

Returns the value of the natural logarithm of 10.

source

pub fn clone(&self) -> Result<Context, Error>

Clones self and returns the cloned context.

Errors
  • MemoryAllocation: failed to allocate memory for the constants cache.

Trait Implementations§

source§

impl Contextable for Context

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§

impl Debug for Context

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V