pub struct OverflowDetection;Expand description
Overflow and underflow detection
Implementations§
Source§impl OverflowDetection
impl OverflowDetection
Sourcepub fn near_overflow<T: Float>(value: T) -> bool
pub fn near_overflow<T: Float>(value: T) -> bool
Check if value is close to overflow
Sourcepub fn near_underflow<T: Float>(value: T) -> bool
pub fn near_underflow<T: Float>(value: T) -> bool
Check if value is close to underflow
Sourcepub fn safe_add<T: Float>(a: T, b: T) -> UtilsResult<T>
pub fn safe_add<T: Float>(a: T, b: T) -> UtilsResult<T>
Safe addition that detects overflow
Sourcepub fn safe_mul<T: Float>(a: T, b: T) -> UtilsResult<T>
pub fn safe_mul<T: Float>(a: T, b: T) -> UtilsResult<T>
Safe multiplication that detects overflow
Sourcepub fn safe_div<T: Float>(a: T, b: T) -> UtilsResult<T>
pub fn safe_div<T: Float>(a: T, b: T) -> UtilsResult<T>
Safe division that handles division by zero and overflow
Auto Trait Implementations§
impl Freeze for OverflowDetection
impl RefUnwindSafe for OverflowDetection
impl Send for OverflowDetection
impl Sync for OverflowDetection
impl Unpin for OverflowDetection
impl UnwindSafe for OverflowDetection
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
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>
Converts
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>
Converts
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