radix_common/math/
traits.rs1pub trait CheckedAdd<Rhs = Self> {
2 type Output;
3
4 fn checked_add(self, other: Rhs) -> Option<Self::Output>
5 where
6 Self: Sized;
7}
8
9pub trait SaturatingAdd<Rhs = Self> {
10 type Output;
11
12 fn saturating_add(self, other: Rhs) -> Self::Output
13 where
14 Self: Sized;
15}
16
17pub trait CheckedSub<Rhs = Self> {
18 type Output;
19
20 fn checked_sub(self, other: Rhs) -> Option<Self::Output>
21 where
22 Self: Sized;
23}
24
25pub trait CheckedMul<Rhs = Self> {
26 type Output;
27
28 fn checked_mul(self, other: Rhs) -> Option<Self::Output>
29 where
30 Self: Sized;
31}
32
33pub trait CheckedDiv<Rhs = Self> {
34 type Output;
35
36 fn checked_div(self, other: Rhs) -> Option<Self::Output>
37 where
38 Self: Sized;
39}
40
41pub trait CheckedNeg<Rhs = Self> {
42 type Output;
43
44 fn checked_neg(self) -> Option<Self::Output>
45 where
46 Self: Sized;
47}