File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -543,6 +543,9 @@ macro_rules! impl_integer_for_isize {
543543 /// Returns `true` if the number is a multiple of `other`.
544544 #[ inline]
545545 fn is_multiple_of( & self , other: & Self ) -> bool {
546+ if other. is_zero( ) {
547+ return self . is_zero( ) ;
548+ }
546549 * self % * other == 0
547550 }
548551
@@ -885,6 +888,9 @@ macro_rules! impl_integer_for_usize {
885888 /// Returns `true` if the number is a multiple of `other`.
886889 #[ inline]
887890 fn is_multiple_of( & self , other: & Self ) -> bool {
891+ if other. is_zero( ) {
892+ return self . is_zero( ) ;
893+ }
888894 * self % * other == 0
889895 }
890896
@@ -981,6 +987,7 @@ macro_rules! impl_integer_for_usize {
981987
982988 #[ test]
983989 fn test_is_multiple_of( ) {
990+ assert!( ( 0 as $T) . is_multiple_of( & ( 0 as $T) ) ) ;
984991 assert!( ( 6 as $T) . is_multiple_of( & ( 6 as $T) ) ) ;
985992 assert!( ( 6 as $T) . is_multiple_of( & ( 3 as $T) ) ) ;
986993 assert!( ( 6 as $T) . is_multiple_of( & ( 1 as $T) ) ) ;
You can’t perform that action at this time.
0 commit comments