diff options
Diffstat (limited to 'src/libcore/ops.rs')
| -rw-r--r-- | src/libcore/ops.rs | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 7ff5026d0b9..bc29a2b4a58 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -113,14 +113,14 @@ pub trait Add<Sized? RHS,Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! add_impl( +macro_rules! add_impl { ($($t:ty)*) => ($( impl Add<$t, $t> for $t { #[inline] fn add(&self, other: &$t) -> $t { (*self) + (*other) } } )*) -) +} /// The `Add` trait is used to specify the functionality of `+`. /// @@ -151,16 +151,16 @@ pub trait Add<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! add_impl( +macro_rules! add_impl { ($($t:ty)*) => ($( impl Add<$t, $t> for $t { #[inline] fn add(self, other: $t) -> $t { self + other } } )*) -) +} -add_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// The `Sub` trait is used to specify the functionality of `-`. /// @@ -195,14 +195,14 @@ pub trait Sub<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! sub_impl( +macro_rules! sub_impl { ($($t:ty)*) => ($( impl Sub<$t, $t> for $t { #[inline] fn sub(&self, other: &$t) -> $t { (*self) - (*other) } } )*) -) +} /// The `Sub` trait is used to specify the functionality of `-`. /// @@ -233,16 +233,16 @@ pub trait Sub<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! sub_impl( +macro_rules! sub_impl { ($($t:ty)*) => ($( impl Sub<$t, $t> for $t { #[inline] fn sub(self, other: $t) -> $t { self - other } } )*) -) +} -sub_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// The `Mul` trait is used to specify the functionality of `*`. /// @@ -277,14 +277,14 @@ pub trait Mul<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! mul_impl( +macro_rules! mul_impl { ($($t:ty)*) => ($( impl Mul<$t, $t> for $t { #[inline] fn mul(&self, other: &$t) -> $t { (*self) * (*other) } } )*) -) +} /// The `Mul` trait is used to specify the functionality of `*`. /// @@ -315,16 +315,16 @@ pub trait Mul<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! mul_impl( +macro_rules! mul_impl { ($($t:ty)*) => ($( impl Mul<$t, $t> for $t { #[inline] fn mul(self, other: $t) -> $t { self * other } } )*) -) +} -mul_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// The `Div` trait is used to specify the functionality of `/`. /// @@ -359,14 +359,14 @@ pub trait Div<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! div_impl( +macro_rules! div_impl { ($($t:ty)*) => ($( impl Div<$t, $t> for $t { #[inline] fn div(&self, other: &$t) -> $t { (*self) / (*other) } } )*) -) +} /// The `Div` trait is used to specify the functionality of `/`. /// @@ -397,16 +397,16 @@ pub trait Div<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! div_impl( +macro_rules! div_impl { ($($t:ty)*) => ($( impl Div<$t, $t> for $t { #[inline] fn div(self, other: $t) -> $t { self / other } } )*) -) +} -div_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// The `Rem` trait is used to specify the functionality of `%`. /// @@ -441,18 +441,18 @@ pub trait Rem<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! rem_impl( +macro_rules! rem_impl { ($($t:ty)*) => ($( impl Rem<$t, $t> for $t { #[inline] fn rem(&self, other: &$t) -> $t { (*self) % (*other) } } )*) -) +} // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! rem_float_impl( +macro_rules! rem_float_impl { ($t:ty, $fmod:ident) => { impl Rem<$t, $t> for $t { #[inline] @@ -462,7 +462,7 @@ macro_rules! rem_float_impl( } } } -) +} /// The `Rem` trait is used to specify the functionality of `%`. /// @@ -493,17 +493,17 @@ pub trait Rem<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! rem_impl( +macro_rules! rem_impl { ($($t:ty)*) => ($( impl Rem<$t, $t> for $t { #[inline] fn rem(self, other: $t) -> $t { self % other } } )*) -) +} #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! rem_float_impl( +macro_rules! rem_float_impl { ($t:ty, $fmod:ident) => { impl Rem<$t, $t> for $t { #[inline] @@ -513,11 +513,11 @@ macro_rules! rem_float_impl( } } } -) +} -rem_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64) -rem_float_impl!(f32, fmodf) -rem_float_impl!(f64, fmod) +rem_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } +rem_float_impl! { f32, fmodf } +rem_float_impl! { f64, fmod } /// The `Neg` trait is used to specify the functionality of unary `-`. /// @@ -548,31 +548,31 @@ pub trait Neg<Result> for Sized? { fn neg(&self) -> Result; } -macro_rules! neg_impl( +macro_rules! neg_impl { ($($t:ty)*) => ($( impl Neg<$t> for $t { #[inline] fn neg(&self) -> $t { -*self } } )*) -) +} -macro_rules! neg_uint_impl( +macro_rules! neg_uint_impl { ($t:ty, $t_signed:ty) => { impl Neg<$t> for $t { #[inline] fn neg(&self) -> $t { -(*self as $t_signed) as $t } } } -) +} -neg_impl!(int i8 i16 i32 i64 f32 f64) +neg_impl! { int i8 i16 i32 i64 f32 f64 } -neg_uint_impl!(uint, int) -neg_uint_impl!(u8, i8) -neg_uint_impl!(u16, i16) -neg_uint_impl!(u32, i32) -neg_uint_impl!(u64, i64) +neg_uint_impl! { uint, int } +neg_uint_impl! { u8, i8 } +neg_uint_impl! { u16, i16 } +neg_uint_impl! { u32, i32 } +neg_uint_impl! { u64, i64 } /// The `Not` trait is used to specify the functionality of unary `!`. @@ -605,16 +605,16 @@ pub trait Not<Result> for Sized? { } -macro_rules! not_impl( +macro_rules! not_impl { ($($t:ty)*) => ($( impl Not<$t> for $t { #[inline] fn not(&self) -> $t { !*self } } )*) -) +} -not_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64) +not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `BitAnd` trait is used to specify the functionality of `&`. /// @@ -649,14 +649,14 @@ pub trait BitAnd<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! bitand_impl( +macro_rules! bitand_impl { ($($t:ty)*) => ($( impl BitAnd<$t, $t> for $t { #[inline] fn bitand(&self, rhs: &$t) -> $t { (*self) & (*rhs) } } )*) -) +} /// The `BitAnd` trait is used to specify the functionality of `&`. /// @@ -687,16 +687,16 @@ pub trait BitAnd<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! bitand_impl( +macro_rules! bitand_impl { ($($t:ty)*) => ($( impl BitAnd<$t, $t> for $t { #[inline] fn bitand(self, rhs: $t) -> $t { self & rhs } } )*) -) +} -bitand_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64) +bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `BitOr` trait is used to specify the functionality of `|`. /// @@ -731,14 +731,14 @@ pub trait BitOr<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! bitor_impl( +macro_rules! bitor_impl { ($($t:ty)*) => ($( impl BitOr<$t,$t> for $t { #[inline] fn bitor(&self, rhs: &$t) -> $t { (*self) | (*rhs) } } )*) -) +} /// The `BitOr` trait is used to specify the functionality of `|`. /// @@ -769,16 +769,16 @@ pub trait BitOr<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! bitor_impl( +macro_rules! bitor_impl { ($($t:ty)*) => ($( impl BitOr<$t,$t> for $t { #[inline] fn bitor(self, rhs: $t) -> $t { self | rhs } } )*) -) +} -bitor_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64) +bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `BitXor` trait is used to specify the functionality of `^`. /// @@ -813,14 +813,14 @@ pub trait BitXor<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! bitxor_impl( +macro_rules! bitxor_impl { ($($t:ty)*) => ($( impl BitXor<$t, $t> for $t { #[inline] fn bitxor(&self, other: &$t) -> $t { (*self) ^ (*other) } } )*) -) +} /// The `BitXor` trait is used to specify the functionality of `^`. /// @@ -851,16 +851,16 @@ pub trait BitXor<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! bitxor_impl( +macro_rules! bitxor_impl { ($($t:ty)*) => ($( impl BitXor<$t, $t> for $t { #[inline] fn bitxor(self, other: $t) -> $t { self ^ other } } )*) -) +} -bitxor_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64) +bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `Shl` trait is used to specify the functionality of `<<`. /// @@ -895,7 +895,7 @@ pub trait Shl<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! shl_impl( +macro_rules! shl_impl { ($($t:ty)*) => ($( impl Shl<uint, $t> for $t { #[inline] @@ -904,7 +904,7 @@ macro_rules! shl_impl( } } )*) -) +} /// The `Shl` trait is used to specify the functionality of `<<`. /// @@ -935,7 +935,7 @@ pub trait Shl<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! shl_impl( +macro_rules! shl_impl { ($($t:ty)*) => ($( impl Shl<uint, $t> for $t { #[inline] @@ -944,9 +944,9 @@ macro_rules! shl_impl( } } )*) -) +} -shl_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64) +shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `Shr` trait is used to specify the functionality of `>>`. /// @@ -981,14 +981,14 @@ pub trait Shr<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! shr_impl( +macro_rules! shr_impl { ($($t:ty)*) => ($( impl Shr<uint, $t> for $t { #[inline] fn shr(&self, other: &uint) -> $t { (*self) >> (*other) } } )*) -) +} /// The `Shr` trait is used to specify the functionality of `>>`. /// @@ -1019,16 +1019,16 @@ pub trait Shr<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! shr_impl( +macro_rules! shr_impl { ($($t:ty)*) => ($( impl Shr<uint, $t> for $t { #[inline] fn shr(self, other: uint) -> $t { self >> other } } )*) -) +} -shr_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64) +shr_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `Index` trait is used to specify the functionality of indexing operations /// like `arr[idx]` when used in an immutable context. |
