concision_traits/ops/
unary.rs1pub trait Decrement {
9 type Output;
10
11 fn dec(self) -> Self::Output;
12}
13
14pub trait DecrementMut {
17 fn dec_mut(&mut self);
18}
19pub trait Increment {
21 type Output;
22
23 fn inc(self) -> Self::Output;
24}
25
26pub trait IncrementMut {
27 fn inc_mut(&mut self);
28}
29
30use num_traits::One;
34
35impl<T> Decrement for T
36where
37 T: One + core::ops::Sub<Output = T>,
38{
39 type Output = T;
40
41 fn dec(self) -> Self::Output {
42 self - T::one()
43 }
44}
45
46impl<T> DecrementMut for T
47where
48 T: One + core::ops::SubAssign,
49{
50 fn dec_mut(&mut self) {
51 *self -= T::one()
52 }
53}
54
55impl<T> Increment for T
56where
57 T: One + core::ops::Add<Output = T>,
58{
59 type Output = T;
60
61 fn inc(self) -> Self::Output {
62 self + T::one()
63 }
64}