|
@@ -15,9 +15,10 @@ macro_rules! overflowing_impl {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-/// If an overflow would have occurred then the wrapped value is returned.
|
|
|
+/// Performs addition with a flag for overflow.
|
|
|
pub trait OverflowingAdd: Sized + Add<Self, Output = Self> {
|
|
|
/// Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur.
|
|
|
+ /// If an overflow would have occurred then the wrapped value is returned.
|
|
|
fn overflowing_add(&self, v: &Self) -> (Self, bool);
|
|
|
}
|
|
|
|
|
@@ -37,9 +38,10 @@ overflowing_impl!(OverflowingAdd, overflowing_add, isize);
|
|
|
#[cfg(has_i128)]
|
|
|
overflowing_impl!(OverflowingAdd, overflowing_add, i128);
|
|
|
|
|
|
-/// If an overflow would have occurred then the wrapped value is returned.
|
|
|
+/// Performs substraction with a flag for overflow.
|
|
|
pub trait OverflowingSub: Sized + Sub<Self, Output = Self> {
|
|
|
/// Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur.
|
|
|
+ /// If an overflow would have occurred then the wrapped value is returned.
|
|
|
fn overflowing_sub(&self, v: &Self) -> (Self, bool);
|
|
|
}
|
|
|
|
|
@@ -59,9 +61,10 @@ overflowing_impl!(OverflowingSub, overflowing_sub, isize);
|
|
|
#[cfg(has_i128)]
|
|
|
overflowing_impl!(OverflowingSub, overflowing_sub, i128);
|
|
|
|
|
|
-/// If an overflow would have occurred then the wrapped value is returned.
|
|
|
+/// Performs multiplication with a flag for overflow.
|
|
|
pub trait OverflowingMul: Sized + Mul<Self, Output = Self> {
|
|
|
/// Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur.
|
|
|
+ /// If an overflow would have occurred then the wrapped value is returned.
|
|
|
fn overflowing_mul(&self, v: &Self) -> (Self, bool);
|
|
|
}
|
|
|
|