pub struct Context { /* private fields */ }Expand description
§Decimal Context
The context represents the user-selectable parameters and rules which govern the results of arithmetic operations (for example, the rounding mode when rounding occurs).
Implementations§
Source§impl Context
impl Context
Sourcepub const fn default() -> Self
pub const fn default() -> Self
Returns the Default Decimal Context.
Sourcepub const fn with_rounding_mode(self, rm: RoundingMode) -> Self
pub const fn with_rounding_mode(self, rm: RoundingMode) -> Self
Apply the given RoundingMode to the Context.
Sourcepub const fn without_traps(self) -> Self
pub const fn without_traps(self) -> Self
Apply no traps to given Context.
Sourcepub const fn with_signal_traps(self, traps: SignalsTraps) -> Self
pub const fn with_signal_traps(self, traps: SignalsTraps) -> Self
Method applies specified SignalsTraps to the given context.
§Examples
use fastnum::{*, decimal::*};
let ctx = Context::default().without_traps();
// No panic! We can divide by zero!
let res = dec256!(1.0).with_ctx(ctx) / dec256!(0).with_ctx(ctx);
assert!(res.is_infinite());
assert!(res.is_op_div_by_zero());
assert!(res.is_op_invalid());Sourcepub const fn rounding_mode(&self) -> RoundingMode
pub const fn rounding_mode(&self) -> RoundingMode
Get RoundingMode of given Context.
Sourcepub const fn signal_traps(&self) -> SignalsTraps
pub const fn signal_traps(&self) -> SignalsTraps
Get SignalsTraps of given Context.
Trait Implementations§
impl Copy for Context
impl Eq for Context
impl StructuralPartialEq for Context
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
Mutably borrows from an owned value. Read more