@@ -77,16 +77,20 @@ pub trait Integer: Num + PartialOrd
7777 /// ~~~
7878 fn lcm ( & self , other : & Self ) -> Self ;
7979
80- /// Returns `true` if `other` divides evenly into `self`.
80+ /// Deprecated, use `is_multiple_of` instead.
81+ #[ deprecated = "function renamed to `is_multiple_of`" ]
82+ fn divides ( & self , other : & Self ) -> bool ;
83+
84+ /// Returns `true` if `other` is a multiple of `self`.
8185 ///
8286 /// # Examples
8387 ///
8488 /// ~~~
8589 /// # use num::Integer;
86- /// assert_eq!(9i.divides (&3), true);
87- /// assert_eq!(3i.divides (&9), false);
90+ /// assert_eq!(9i.is_multiple_of (&3), true);
91+ /// assert_eq!(3i.is_multiple_of (&9), false);
8892 /// ~~~
89- fn divides ( & self , other : & Self ) -> bool ;
93+ fn is_multiple_of ( & self , other : & Self ) -> bool ;
9094
9195 /// Returns `true` if the number is even.
9296 ///
@@ -231,10 +235,14 @@ macro_rules! impl_integer_for_int {
231235 ( ( * self * * other) / self . gcd( other) ) . abs( )
232236 }
233237
234- /// Returns `true` if the number can be divided by `other` without
235- /// leaving a remainder
238+ /// Deprecated, use `is_multiple_of` instead.
239+ #[ deprecated = "function renamed to `is_multiple_of`" ]
240+ #[ inline]
241+ fn divides( & self , other: & $T) -> bool { return self . is_multiple_of( other) ; }
242+
243+ /// Returns `true` if the number is a multiple of `other`.
236244 #[ inline]
237- fn divides ( & self , other: & $T) -> bool { * self % * other == 0 }
245+ fn is_multiple_of ( & self , other: & $T) -> bool { * self % * other == 0 }
238246
239247 /// Returns `true` if the number is divisible by `2`
240248 #[ inline]
@@ -393,21 +401,26 @@ macro_rules! impl_integer_for_uint {
393401 n
394402 }
395403
396- /// Calculates the Lowest Common Multiple (LCM) of the number and `other`
404+ /// Calculates the Lowest Common Multiple (LCM) of the number and `other`.
397405 #[ inline]
398406 fn lcm( & self , other: & $T) -> $T {
399407 ( * self * * other) / self . gcd( other)
400408 }
401409
402- /// Returns `true` if the number can be divided by `other` without leaving a remainder
410+ /// Deprecated, use `is_multiple_of` instead.
411+ #[ deprecated = "function renamed to `is_multiple_of`" ]
403412 #[ inline]
404- fn divides( & self , other: & $T) -> bool { * self % * other == 0 }
413+ fn divides( & self , other: & $T) -> bool { return self . is_multiple_of ( other) ; }
405414
406- /// Returns `true` if the number is divisible by `2`
415+ /// Returns `true` if the number is a multiple of `other`.
416+ #[ inline]
417+ fn is_multiple_of( & self , other: & $T) -> bool { * self % * other == 0 }
418+
419+ /// Returns `true` if the number is divisible by `2`.
407420 #[ inline]
408421 fn is_even( & self ) -> bool { self & 1 == 0 }
409422
410- /// Returns `true` if the number is not divisible by `2`
423+ /// Returns `true` if the number is not divisible by `2`.
411424 #[ inline]
412425 fn is_odd( & self ) -> bool { !self . is_even( ) }
413426 }
@@ -449,10 +462,10 @@ macro_rules! impl_integer_for_uint {
449462 }
450463
451464 #[ test]
452- fn test_divides ( ) {
453- assert!( ( 6 as $T) . divides ( & ( 6 as $T) ) ) ;
454- assert!( ( 6 as $T) . divides ( & ( 3 as $T) ) ) ;
455- assert!( ( 6 as $T) . divides ( & ( 1 as $T) ) ) ;
465+ fn test_is_multiple_of ( ) {
466+ assert!( ( 6 as $T) . is_multiple_of ( & ( 6 as $T) ) ) ;
467+ assert!( ( 6 as $T) . is_multiple_of ( & ( 3 as $T) ) ) ;
468+ assert!( ( 6 as $T) . is_multiple_of ( & ( 1 as $T) ) ) ;
456469 }
457470
458471 #[ test]
0 commit comments