Skip to content

Commit b8fcf38

Browse files
committed
Add Integer.dec() and Integer.inc()
1 parent f9ef6c0 commit b8fcf38

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/lib.rs

+16
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,22 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
335335
{
336336
self.clone() - self.mod_floor(other)
337337
}
338+
339+
/// Decrements self.
340+
fn dec(&mut self)
341+
where
342+
Self: Clone,
343+
{
344+
*self = self.clone() - Self::one()
345+
}
346+
347+
/// Increments self.
348+
fn inc(&mut self)
349+
where
350+
Self: Clone,
351+
{
352+
*self = self.clone() + Self::one()
353+
}
338354
}
339355

340356
/// Greatest common divisor and Bézout coefficients

0 commit comments

Comments
 (0)