Skip to content

Commit

Permalink
rename next_multiple_back_of as prev_multiple_of and test more
Browse files Browse the repository at this point in the history
  • Loading branch information
strake committed Feb 23, 2019
1 parent 426f1d0 commit 93176f5
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,14 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
///
/// ~~~
/// # use num_integer::Integer;
/// assert_eq!(16.next_multiple_of(& 8), 16);
/// assert_eq!(23.next_multiple_of(& 8), 24);
/// assert_eq!(16.next_multiple_of(&-8), 16);
/// assert_eq!(23.next_multiple_of(&-8), 16);
/// assert_eq!(( 16).next_multiple_of(& 8), 16);
/// assert_eq!(( 23).next_multiple_of(& 8), 24);
/// assert_eq!(( 16).next_multiple_of(&-8), 16);
/// assert_eq!(( 23).next_multiple_of(&-8), 16);
/// assert_eq!((-16).next_multiple_of(& 8), -16);
/// assert_eq!((-23).next_multiple_of(& 8), -16);
/// assert_eq!((-16).next_multiple_of(&-8), -16);
/// assert_eq!((-23).next_multiple_of(&-8), -24);
/// ~~~
#[inline]
fn next_multiple_of(&self, other: &Self) -> Self where Self: Clone {
Expand All @@ -216,13 +220,17 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
///
/// ~~~
/// # use num_integer::Integer;
/// assert_eq!(16.next_multiple_back_of(& 8), 16);
/// assert_eq!(23.next_multiple_back_of(& 8), 16);
/// assert_eq!(16.next_multiple_back_of(&-8), 16);
/// assert_eq!(23.next_multiple_back_of(&-8), 24);
/// assert_eq!(( 16).prev_multiple_of(& 8), 16);
/// assert_eq!(( 23).prev_multiple_of(& 8), 16);
/// assert_eq!(( 16).prev_multiple_of(&-8), 16);
/// assert_eq!(( 23).prev_multiple_of(&-8), 24);
/// assert_eq!((-16).prev_multiple_of(& 8), -16);
/// assert_eq!((-23).prev_multiple_of(& 8), -24);
/// assert_eq!((-16).prev_multiple_of(&-8), -16);
/// assert_eq!((-23).prev_multiple_of(&-8), -16);
/// ~~~
#[inline]
fn next_multiple_back_of(&self, other: &Self) -> Self where Self: Clone {
fn prev_multiple_of(&self, other: &Self) -> Self where Self: Clone {
self.clone() - self.mod_floor(other)
}
}
Expand Down

0 comments on commit 93176f5

Please sign in to comment.