@@ -315,9 +315,6 @@ mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
315
315
316
316
/// The `Div` trait is used to specify the functionality of `/`.
317
317
///
318
- /// For primitive integral types, this operation rounds towards zero,
319
- /// truncating any fractional part of the exact result.
320
- ///
321
318
/// # Examples
322
319
///
323
320
/// A trivial implementation of `Div`. When `Foo / Foo` happens, it ends up
@@ -354,7 +351,25 @@ pub trait Div<RHS=Self> {
354
351
fn div ( self , rhs : RHS ) -> Self :: Output ;
355
352
}
356
353
357
- macro_rules! div_impl {
354
+ macro_rules! div_impl_integer {
355
+ ( $( $t: ty) * ) => ( $(
356
+ /// This operation rounds towards zero, truncating any
357
+ /// fractional part of the exact result.
358
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
359
+ impl Div for $t {
360
+ type Output = $t;
361
+
362
+ #[ inline]
363
+ fn div( self , other: $t) -> $t { self / other }
364
+ }
365
+
366
+ forward_ref_binop! { impl Div , div for $t, $t }
367
+ ) * )
368
+ }
369
+
370
+ div_impl_integer ! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
371
+
372
+ macro_rules! div_impl_float {
358
373
( $( $t: ty) * ) => ( $(
359
374
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
360
375
impl Div for $t {
@@ -368,13 +383,10 @@ macro_rules! div_impl {
368
383
) * )
369
384
}
370
385
371
- div_impl ! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
386
+ div_impl_float ! { f32 f64 }
372
387
373
388
/// The `Rem` trait is used to specify the functionality of `%`.
374
389
///
375
- /// For primitive integral types, this operation satisfies `n % d == n
376
- /// - (n / d) * d`. The result has the same sign as the left operand.
377
- ///
378
390
/// # Examples
379
391
///
380
392
/// A trivial implementation of `Rem`. When `Foo % Foo` happens, it ends up
@@ -413,6 +425,8 @@ pub trait Rem<RHS=Self> {
413
425
414
426
macro_rules! rem_impl {
415
427
( $( $t: ty) * ) => ( $(
428
+ /// This operation satisfies `n % d == n - (n / d) * d`. The
429
+ /// result has the same sign as the left operand.
416
430
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
417
431
impl Rem for $t {
418
432
type Output = $t;
0 commit comments