pub struct CheckedArithmetic<Kind = Checked>(/* private fields */);Expand description
Arithmetic on an integer type (e.g., i32) that checks overflow and other failure
conditions for all operations.
As an example, this type implements Arithmetic for all built-in integer types
with a definite size (u8, i8, u16, i16, u32, i32, u64, i64, u128, i128).
The type param defines how negation should be performed; it should be one of Checked
(default value), Unchecked or NegateOnlyZero. See the docs for these types for
more details.
Implementations§
Source§impl<Kind> CheckedArithmetic<Kind>
impl<Kind> CheckedArithmetic<Kind>
Trait Implementations§
Source§impl<T, Kind> Arithmetic<T> for CheckedArithmetic<Kind>where
T: Clone + PartialEq + Zero + One + CheckedAdd + CheckedSub + CheckedMul + CheckedDiv,
Kind: CheckedArithmeticKind<T>,
usize: TryFrom<T>,
impl<T, Kind> Arithmetic<T> for CheckedArithmetic<Kind>where
T: Clone + PartialEq + Zero + One + CheckedAdd + CheckedSub + CheckedMul + CheckedDiv,
Kind: CheckedArithmeticKind<T>,
usize: TryFrom<T>,
Source§impl<Kind> Clone for CheckedArithmetic<Kind>
impl<Kind> Clone for CheckedArithmetic<Kind>
Source§impl<Kind: Debug> Debug for CheckedArithmetic<Kind>
impl<Kind: Debug> Debug for CheckedArithmetic<Kind>
Source§impl<Kind> Default for CheckedArithmetic<Kind>
impl<Kind> Default for CheckedArithmetic<Kind>
Source§impl<T, Kind> OrdArithmetic<T> for CheckedArithmetic<Kind>where
Self: Arithmetic<T>,
T: PartialOrd,
impl<T, Kind> OrdArithmetic<T> for CheckedArithmetic<Kind>where
Self: Arithmetic<T>,
T: PartialOrd,
impl<Kind> Copy for CheckedArithmetic<Kind>
Auto Trait Implementations§
impl<Kind> Freeze for CheckedArithmetic<Kind>
impl<Kind> RefUnwindSafe for CheckedArithmetic<Kind>where
Kind: RefUnwindSafe,
impl<Kind> Send for CheckedArithmetic<Kind>where
Kind: Send,
impl<Kind> Sync for CheckedArithmetic<Kind>where
Kind: Sync,
impl<Kind> Unpin for CheckedArithmetic<Kind>where
Kind: Unpin,
impl<Kind> UnwindSafe for CheckedArithmetic<Kind>where
Kind: UnwindSafe,
Blanket Implementations§
Source§impl<T, A> ArithmeticExt<T> for Awhere
A: Arithmetic<T>,
impl<T, A> ArithmeticExt<T> for Awhere
A: Arithmetic<T>,
Source§fn without_comparisons(self) -> FullArithmetic<T, Self>
fn without_comparisons(self) -> FullArithmetic<T, Self>
Combines this arithmetic with a comparison function that assumes any two values are
incomparable.
Source§fn with_natural_comparison(self) -> FullArithmetic<T, Self>where
T: PartialOrd,
fn with_natural_comparison(self) -> FullArithmetic<T, Self>where
T: PartialOrd,
Combines this arithmetic with a comparison function specified by the
PartialOrd
implementation for T.Source§fn with_comparison(
self,
comparison: fn(&T, &T) -> Option<Ordering>,
) -> FullArithmetic<T, Self>
fn with_comparison( self, comparison: fn(&T, &T) -> Option<Ordering>, ) -> FullArithmetic<T, Self>
Combines this arithmetic with the specified comparison function.
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