diff options
Diffstat (limited to 'src/libcore/ops/arith.rs')
| -rw-r--r-- | src/libcore/ops/arith.rs | 91 |
1 files changed, 50 insertions, 41 deletions
diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 3c009d644c6..59a72799e25 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -66,19 +66,13 @@ #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented( - on( - all(_Self="{integer}", Rhs="{float}"), - message="cannot add a float to an integer", - ), - on( - all(_Self="{float}", Rhs="{integer}"), - message="cannot add an integer to a float", - ), - message="cannot add `{Rhs}` to `{Self}`", - label="no implementation for `{Self} + {Rhs}`", + on(all(_Self = "{integer}", Rhs = "{float}"), message = "cannot add a float to an integer",), + on(all(_Self = "{float}", Rhs = "{integer}"), message = "cannot add an integer to a float",), + message = "cannot add `{Rhs}` to `{Self}`", + label = "no implementation for `{Self} + {Rhs}`" )] #[doc(alias = "+")] -pub trait Add<Rhs=Self> { +pub trait Add<Rhs = Self> { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -173,10 +167,12 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot subtract `{Rhs}` from `{Self}`", - label="no implementation for `{Self} - {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot subtract `{Rhs}` from `{Self}`", + label = "no implementation for `{Self} - {Rhs}`" +)] #[doc(alias = "-")] -pub trait Sub<Rhs=Self> { +pub trait Sub<Rhs = Self> { /// The resulting type after applying the `-` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -293,10 +289,12 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot multiply `{Rhs}` to `{Self}`", - label="no implementation for `{Self} * {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot multiply `{Rhs}` to `{Self}`", + label = "no implementation for `{Self} * {Rhs}`" +)] #[doc(alias = "*")] -pub trait Mul<Rhs=Self> { +pub trait Mul<Rhs = Self> { /// The resulting type after applying the `*` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -417,10 +415,12 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot divide `{Self}` by `{Rhs}`", - label="no implementation for `{Self} / {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot divide `{Self}` by `{Rhs}`", + label = "no implementation for `{Self} / {Rhs}`" +)] #[doc(alias = "/")] -pub trait Div<Rhs=Self> { +pub trait Div<Rhs = Self> { /// The resulting type after applying the `/` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -502,10 +502,12 @@ div_impl_float! { f32 f64 } /// ``` #[lang = "rem"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot mod `{Self}` by `{Rhs}`", - label="no implementation for `{Self} % {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot mod `{Self}` by `{Rhs}`", + label = "no implementation for `{Self} % {Rhs}`" +)] #[doc(alias = "%")] -pub trait Rem<Rhs=Self> { +pub trait Rem<Rhs = Self> { /// The resulting type after applying the `%` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -534,7 +536,6 @@ macro_rules! rem_impl_integer { rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } - macro_rules! rem_impl_float { ($($t:ty)*) => ($( @@ -616,8 +617,6 @@ pub trait Neg { fn neg(self) -> Self::Output; } - - macro_rules! neg_impl_core { ($id:ident => $body:expr, $($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] @@ -679,11 +678,13 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "add_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot add-assign `{Rhs}` to `{Self}`", - label="no implementation for `{Self} += {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot add-assign `{Rhs}` to `{Self}`", + label = "no implementation for `{Self} += {Rhs}`" +)] #[doc(alias = "+")] #[doc(alias = "+=")] -pub trait AddAssign<Rhs=Self> { +pub trait AddAssign<Rhs = Self> { /// Performs the `+=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn add_assign(&mut self, rhs: Rhs); @@ -735,11 +736,13 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot subtract-assign `{Rhs}` from `{Self}`", - label="no implementation for `{Self} -= {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot subtract-assign `{Rhs}` from `{Self}`", + label = "no implementation for `{Self} -= {Rhs}`" +)] #[doc(alias = "-")] #[doc(alias = "-=")] -pub trait SubAssign<Rhs=Self> { +pub trait SubAssign<Rhs = Self> { /// Performs the `-=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn sub_assign(&mut self, rhs: Rhs); @@ -782,11 +785,13 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot multiply-assign `{Rhs}` to `{Self}`", - label="no implementation for `{Self} *= {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot multiply-assign `{Rhs}` to `{Self}`", + label = "no implementation for `{Self} *= {Rhs}`" +)] #[doc(alias = "*")] #[doc(alias = "*=")] -pub trait MulAssign<Rhs=Self> { +pub trait MulAssign<Rhs = Self> { /// Performs the `*=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn mul_assign(&mut self, rhs: Rhs); @@ -829,11 +834,13 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot divide-assign `{Self}` by `{Rhs}`", - label="no implementation for `{Self} /= {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot divide-assign `{Self}` by `{Rhs}`", + label = "no implementation for `{Self} /= {Rhs}`" +)] #[doc(alias = "/")] #[doc(alias = "/=")] -pub trait DivAssign<Rhs=Self> { +pub trait DivAssign<Rhs = Self> { /// Performs the `/=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn div_assign(&mut self, rhs: Rhs); @@ -879,11 +886,13 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "rem_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot mod-assign `{Self}` by `{Rhs}``", - label="no implementation for `{Self} %= {Rhs}`")] +#[rustc_on_unimplemented( + message = "cannot mod-assign `{Self}` by `{Rhs}``", + label = "no implementation for `{Self} %= {Rhs}`" +)] #[doc(alias = "%")] #[doc(alias = "%=")] -pub trait RemAssign<Rhs=Self> { +pub trait RemAssign<Rhs = Self> { /// Performs the `%=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] fn rem_assign(&mut self, rhs: Rhs); |
