Skip to content

Commit

Permalink
Add Integer.dec() and Integer.inc()
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelX413 committed Oct 13, 2022
1 parent f9ef6c0 commit b8fcf38
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,22 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
{
self.clone() - self.mod_floor(other)
}

/// Decrements self.
fn dec(&mut self)
where
Self: Clone,
{
*self = self.clone() - Self::one()
}

/// Increments self.
fn inc(&mut self)
where
Self: Clone,
{
*self = self.clone() + Self::one()
}
}

/// Greatest common divisor and Bézout coefficients
Expand Down

0 comments on commit b8fcf38

Please sign in to comment.