@@ -91,7 +91,11 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
9191 /// ~~~
9292 fn div_ceil ( & self , other : & Self ) -> Self {
9393 let ( q, r) = self . div_mod_floor ( other) ;
94- if r. is_zero ( ) { q } else { q+Self :: one ( ) }
94+ if r. is_zero ( ) {
95+ q
96+ } else {
97+ q + Self :: one ( )
98+ }
9599 }
96100
97101 /// Greatest Common Divisor (GCD).
@@ -213,9 +217,17 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
213217 /// assert_eq!((-23).next_multiple_of(&-8), -24);
214218 /// ~~~
215219 #[ inline]
216- fn next_multiple_of ( & self , other : & Self ) -> Self where Self : Clone {
220+ fn next_multiple_of ( & self , other : & Self ) -> Self
221+ where
222+ Self : Clone ,
223+ {
217224 let m = self . mod_floor ( other) ;
218- self . clone ( ) + if m. is_zero ( ) { Self :: zero ( ) } else { other. clone ( ) - m }
225+ self . clone ( )
226+ + if m. is_zero ( ) {
227+ Self :: zero ( )
228+ } else {
229+ other. clone ( ) - m
230+ }
219231 }
220232
221233 /// Rounds down to nearest multiple of argument.
@@ -238,7 +250,10 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
238250 /// assert_eq!((-23).prev_multiple_of(&-8), -16);
239251 /// ~~~
240252 #[ inline]
241- fn prev_multiple_of ( & self , other : & Self ) -> Self where Self : Clone {
253+ fn prev_multiple_of ( & self , other : & Self ) -> Self
254+ where
255+ Self : Clone ,
256+ {
242257 self . clone ( ) - self . mod_floor ( other)
243258 }
244259}
@@ -322,10 +337,11 @@ macro_rules! impl_integer_for_isize {
322337
323338 #[ inline]
324339 fn div_ceil( & self , other: & Self ) -> Self {
325- match self . div_rem( other) {
326- ( d, r) if ( r > 0 && * other > 0 )
327- || ( r < 0 && * other < 0 ) => d + 1 ,
328- ( d, _) => d,
340+ let ( d, r) = self . div_rem( other) ;
341+ if ( r > 0 && * other > 0 ) || ( r < 0 && * other < 0 ) {
342+ d + 1
343+ } else {
344+ d
329345 }
330346 }
331347
0 commit comments