1#[lang = "add"]
67#[stable(feature = "rust1", since = "1.0.0")]
68#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
69#[rustc_on_unimplemented(
70 on(all(Self = "{integer}", Rhs = "{float}"), message = "cannot add a float to an integer",),
71 on(all(Self = "{float}", Rhs = "{integer}"), message = "cannot add an integer to a float",),
72 message = "cannot add `{Rhs}` to `{Self}`",
73 label = "no implementation for `{Self} + {Rhs}`"
74)]
75#[doc(alias = "+")]
76pub const trait Add<Rhs = Self> {
77 #[stable(feature = "rust1", since = "1.0.0")]
79 type Output;
80
81 #[must_use = "this returns the result of the operation, without modifying the original"]
89 #[rustc_diagnostic_item = "add"]
90 #[stable(feature = "rust1", since = "1.0.0")]
91 fn add(self, rhs: Rhs) -> Self::Output;
92}
93
94macro_rules! add_impl {
95 ($($t:ty)*) => ($(
96 #[stable(feature = "rust1", since = "1.0.0")]
97 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
98 const impl Add for $t {
99 type Output = $t;
100
101 #[inline]
102 #[track_caller]
103 #[rustc_inherit_overflow_checks]
104 fn add(self, other: $t) -> $t { self + other }
105 }
106
107 forward_ref_binop! { impl Add, add for $t, $t,
108 #[stable(feature = "rust1", since = "1.0.0")]
109 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
110 )*)
111}
112
113#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for usize {
type Output = usize;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: usize) -> usize { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<usize> for &usize {
type Output = <usize as Add<usize>>::Output;
#[inline]
#[track_caller]
fn add(self, other: usize) -> <usize as Add<usize>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&usize> for usize {
type Output = <usize as Add<usize>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &usize) -> <usize as Add<usize>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&usize> for &usize {
type Output = <usize as Add<usize>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &usize) -> <usize as Add<usize>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for u8 {
type Output = u8;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: u8) -> u8 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<u8> for &u8 {
type Output = <u8 as Add<u8>>::Output;
#[inline]
#[track_caller]
fn add(self, other: u8) -> <u8 as Add<u8>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u8> for u8 {
type Output = <u8 as Add<u8>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u8) -> <u8 as Add<u8>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u8> for &u8 {
type Output = <u8 as Add<u8>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u8) -> <u8 as Add<u8>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for u16 {
type Output = u16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: u16) -> u16 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<u16> for &u16 {
type Output = <u16 as Add<u16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: u16) -> <u16 as Add<u16>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u16> for u16 {
type Output = <u16 as Add<u16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u16) -> <u16 as Add<u16>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u16> for &u16 {
type Output = <u16 as Add<u16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u16) -> <u16 as Add<u16>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for u32 {
type Output = u32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: u32) -> u32 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<u32> for &u32 {
type Output = <u32 as Add<u32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: u32) -> <u32 as Add<u32>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u32> for u32 {
type Output = <u32 as Add<u32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u32) -> <u32 as Add<u32>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u32> for &u32 {
type Output = <u32 as Add<u32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u32) -> <u32 as Add<u32>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for u64 {
type Output = u64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: u64) -> u64 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<u64> for &u64 {
type Output = <u64 as Add<u64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: u64) -> <u64 as Add<u64>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u64> for u64 {
type Output = <u64 as Add<u64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u64) -> <u64 as Add<u64>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u64> for &u64 {
type Output = <u64 as Add<u64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u64) -> <u64 as Add<u64>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for u128 {
type Output = u128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: u128) -> u128 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<u128> for &u128 {
type Output = <u128 as Add<u128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: u128) -> <u128 as Add<u128>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u128> for u128 {
type Output = <u128 as Add<u128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u128) -> <u128 as Add<u128>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&u128> for &u128 {
type Output = <u128 as Add<u128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &u128) -> <u128 as Add<u128>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for isize {
type Output = isize;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: isize) -> isize { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<isize> for &isize {
type Output = <isize as Add<isize>>::Output;
#[inline]
#[track_caller]
fn add(self, other: isize) -> <isize as Add<isize>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&isize> for isize {
type Output = <isize as Add<isize>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &isize) -> <isize as Add<isize>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&isize> for &isize {
type Output = <isize as Add<isize>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &isize) -> <isize as Add<isize>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for i8 {
type Output = i8;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: i8) -> i8 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<i8> for &i8 {
type Output = <i8 as Add<i8>>::Output;
#[inline]
#[track_caller]
fn add(self, other: i8) -> <i8 as Add<i8>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i8> for i8 {
type Output = <i8 as Add<i8>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i8) -> <i8 as Add<i8>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i8> for &i8 {
type Output = <i8 as Add<i8>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i8) -> <i8 as Add<i8>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for i16 {
type Output = i16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: i16) -> i16 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<i16> for &i16 {
type Output = <i16 as Add<i16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: i16) -> <i16 as Add<i16>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i16> for i16 {
type Output = <i16 as Add<i16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i16) -> <i16 as Add<i16>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i16> for &i16 {
type Output = <i16 as Add<i16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i16) -> <i16 as Add<i16>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for i32 {
type Output = i32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: i32) -> i32 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<i32> for &i32 {
type Output = <i32 as Add<i32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: i32) -> <i32 as Add<i32>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i32> for i32 {
type Output = <i32 as Add<i32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i32) -> <i32 as Add<i32>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i32> for &i32 {
type Output = <i32 as Add<i32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i32) -> <i32 as Add<i32>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for i64 {
type Output = i64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: i64) -> i64 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<i64> for &i64 {
type Output = <i64 as Add<i64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: i64) -> <i64 as Add<i64>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i64> for i64 {
type Output = <i64 as Add<i64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i64) -> <i64 as Add<i64>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i64> for &i64 {
type Output = <i64 as Add<i64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i64) -> <i64 as Add<i64>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for i128 {
type Output = i128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: i128) -> i128 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<i128> for &i128 {
type Output = <i128 as Add<i128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: i128) -> <i128 as Add<i128>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i128> for i128 {
type Output = <i128 as Add<i128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i128) -> <i128 as Add<i128>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&i128> for &i128 {
type Output = <i128 as Add<i128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &i128) -> <i128 as Add<i128>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for f16 {
type Output = f16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: f16) -> f16 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<f16> for &f16 {
type Output = <f16 as Add<f16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: f16) -> <f16 as Add<f16>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&f16> for f16 {
type Output = <f16 as Add<f16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &f16) -> <f16 as Add<f16>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&f16> for &f16 {
type Output = <f16 as Add<f16>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &f16) -> <f16 as Add<f16>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for f32 {
type Output = f32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: f32) -> f32 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<f32> for &f32 {
type Output = <f32 as Add<f32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: f32) -> <f32 as Add<f32>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&f32> for f32 {
type Output = <f32 as Add<f32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &f32) -> <f32 as Add<f32>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&f32> for &f32 {
type Output = <f32 as Add<f32>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &f32) -> <f32 as Add<f32>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for f64 {
type Output = f64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: f64) -> f64 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<f64> for &f64 {
type Output = <f64 as Add<f64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: f64) -> <f64 as Add<f64>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&f64> for f64 {
type Output = <f64 as Add<f64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &f64) -> <f64 as Add<f64>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&f64> for &f64 {
type Output = <f64 as Add<f64>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &f64) -> <f64 as Add<f64>>::Output {
Add::add(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add for f128 {
type Output = f128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add(self, other: f128) -> f128 { self + other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<f128> for &f128 {
type Output = <f128 as Add<f128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: f128) -> <f128 as Add<f128>>::Output {
Add::add(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&f128> for f128 {
type Output = <f128 as Add<f128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &f128) -> <f128 as Add<f128>>::Output {
Add::add(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Add<&f128> for &f128 {
type Output = <f128 as Add<f128>>::Output;
#[inline]
#[track_caller]
fn add(self, other: &f128) -> <f128 as Add<f128>>::Output {
Add::add(*self, *other)
}
}add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
114
115#[lang = "sub"]
181#[stable(feature = "rust1", since = "1.0.0")]
182#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
183#[diagnostic::on_unimplemented(
184 message = "cannot subtract `{Rhs}` from `{Self}`",
185 label = "no implementation for `{Self} - {Rhs}`"
186)]
187#[doc(alias = "-")]
188pub const trait Sub<Rhs = Self> {
189 #[stable(feature = "rust1", since = "1.0.0")]
191 type Output;
192
193 #[must_use = "this returns the result of the operation, without modifying the original"]
201 #[rustc_diagnostic_item = "sub"]
202 #[stable(feature = "rust1", since = "1.0.0")]
203 fn sub(self, rhs: Rhs) -> Self::Output;
204}
205
206macro_rules! sub_impl {
207 ($($t:ty)*) => ($(
208 #[stable(feature = "rust1", since = "1.0.0")]
209 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
210 const impl Sub for $t {
211 type Output = $t;
212
213 #[inline]
214 #[track_caller]
215 #[rustc_inherit_overflow_checks]
216 fn sub(self, other: $t) -> $t { self - other }
217 }
218
219 forward_ref_binop! { impl Sub, sub for $t, $t,
220 #[stable(feature = "rust1", since = "1.0.0")]
221 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
222 )*)
223}
224
225#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for usize {
type Output = usize;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: usize) -> usize { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<usize> for &usize {
type Output = <usize as Sub<usize>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: usize) -> <usize as Sub<usize>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&usize> for usize {
type Output = <usize as Sub<usize>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &usize) -> <usize as Sub<usize>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&usize> for &usize {
type Output = <usize as Sub<usize>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &usize) -> <usize as Sub<usize>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for u8 {
type Output = u8;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: u8) -> u8 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<u8> for &u8 {
type Output = <u8 as Sub<u8>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: u8) -> <u8 as Sub<u8>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u8> for u8 {
type Output = <u8 as Sub<u8>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u8) -> <u8 as Sub<u8>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u8> for &u8 {
type Output = <u8 as Sub<u8>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u8) -> <u8 as Sub<u8>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for u16 {
type Output = u16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: u16) -> u16 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<u16> for &u16 {
type Output = <u16 as Sub<u16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: u16) -> <u16 as Sub<u16>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u16> for u16 {
type Output = <u16 as Sub<u16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u16) -> <u16 as Sub<u16>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u16> for &u16 {
type Output = <u16 as Sub<u16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u16) -> <u16 as Sub<u16>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for u32 {
type Output = u32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: u32) -> u32 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<u32> for &u32 {
type Output = <u32 as Sub<u32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: u32) -> <u32 as Sub<u32>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u32> for u32 {
type Output = <u32 as Sub<u32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u32) -> <u32 as Sub<u32>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u32> for &u32 {
type Output = <u32 as Sub<u32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u32) -> <u32 as Sub<u32>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for u64 {
type Output = u64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: u64) -> u64 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<u64> for &u64 {
type Output = <u64 as Sub<u64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: u64) -> <u64 as Sub<u64>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u64> for u64 {
type Output = <u64 as Sub<u64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u64) -> <u64 as Sub<u64>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u64> for &u64 {
type Output = <u64 as Sub<u64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u64) -> <u64 as Sub<u64>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for u128 {
type Output = u128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: u128) -> u128 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<u128> for &u128 {
type Output = <u128 as Sub<u128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: u128) -> <u128 as Sub<u128>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u128> for u128 {
type Output = <u128 as Sub<u128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u128) -> <u128 as Sub<u128>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&u128> for &u128 {
type Output = <u128 as Sub<u128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &u128) -> <u128 as Sub<u128>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for isize {
type Output = isize;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: isize) -> isize { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<isize> for &isize {
type Output = <isize as Sub<isize>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: isize) -> <isize as Sub<isize>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&isize> for isize {
type Output = <isize as Sub<isize>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &isize) -> <isize as Sub<isize>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&isize> for &isize {
type Output = <isize as Sub<isize>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &isize) -> <isize as Sub<isize>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for i8 {
type Output = i8;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: i8) -> i8 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<i8> for &i8 {
type Output = <i8 as Sub<i8>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: i8) -> <i8 as Sub<i8>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i8> for i8 {
type Output = <i8 as Sub<i8>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i8) -> <i8 as Sub<i8>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i8> for &i8 {
type Output = <i8 as Sub<i8>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i8) -> <i8 as Sub<i8>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for i16 {
type Output = i16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: i16) -> i16 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<i16> for &i16 {
type Output = <i16 as Sub<i16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: i16) -> <i16 as Sub<i16>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i16> for i16 {
type Output = <i16 as Sub<i16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i16) -> <i16 as Sub<i16>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i16> for &i16 {
type Output = <i16 as Sub<i16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i16) -> <i16 as Sub<i16>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for i32 {
type Output = i32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: i32) -> i32 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<i32> for &i32 {
type Output = <i32 as Sub<i32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: i32) -> <i32 as Sub<i32>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i32> for i32 {
type Output = <i32 as Sub<i32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i32) -> <i32 as Sub<i32>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i32> for &i32 {
type Output = <i32 as Sub<i32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i32) -> <i32 as Sub<i32>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for i64 {
type Output = i64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: i64) -> i64 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<i64> for &i64 {
type Output = <i64 as Sub<i64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: i64) -> <i64 as Sub<i64>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i64> for i64 {
type Output = <i64 as Sub<i64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i64) -> <i64 as Sub<i64>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i64> for &i64 {
type Output = <i64 as Sub<i64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i64) -> <i64 as Sub<i64>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for i128 {
type Output = i128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: i128) -> i128 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<i128> for &i128 {
type Output = <i128 as Sub<i128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: i128) -> <i128 as Sub<i128>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i128> for i128 {
type Output = <i128 as Sub<i128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i128) -> <i128 as Sub<i128>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&i128> for &i128 {
type Output = <i128 as Sub<i128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &i128) -> <i128 as Sub<i128>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for f16 {
type Output = f16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: f16) -> f16 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<f16> for &f16 {
type Output = <f16 as Sub<f16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: f16) -> <f16 as Sub<f16>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&f16> for f16 {
type Output = <f16 as Sub<f16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &f16) -> <f16 as Sub<f16>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&f16> for &f16 {
type Output = <f16 as Sub<f16>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &f16) -> <f16 as Sub<f16>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for f32 {
type Output = f32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: f32) -> f32 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<f32> for &f32 {
type Output = <f32 as Sub<f32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: f32) -> <f32 as Sub<f32>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&f32> for f32 {
type Output = <f32 as Sub<f32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &f32) -> <f32 as Sub<f32>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&f32> for &f32 {
type Output = <f32 as Sub<f32>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &f32) -> <f32 as Sub<f32>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for f64 {
type Output = f64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: f64) -> f64 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<f64> for &f64 {
type Output = <f64 as Sub<f64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: f64) -> <f64 as Sub<f64>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&f64> for f64 {
type Output = <f64 as Sub<f64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &f64) -> <f64 as Sub<f64>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&f64> for &f64 {
type Output = <f64 as Sub<f64>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &f64) -> <f64 as Sub<f64>>::Output {
Sub::sub(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub for f128 {
type Output = f128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub(self, other: f128) -> f128 { self - other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<f128> for &f128 {
type Output = <f128 as Sub<f128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: f128) -> <f128 as Sub<f128>>::Output {
Sub::sub(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&f128> for f128 {
type Output = <f128 as Sub<f128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &f128) -> <f128 as Sub<f128>>::Output {
Sub::sub(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Sub<&f128> for &f128 {
type Output = <f128 as Sub<f128>>::Output;
#[inline]
#[track_caller]
fn sub(self, other: &f128) -> <f128 as Sub<f128>>::Output {
Sub::sub(*self, *other)
}
}sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
226
227#[lang = "mul"]
315#[stable(feature = "rust1", since = "1.0.0")]
316#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
317#[diagnostic::on_unimplemented(
318 message = "cannot multiply `{Self}` by `{Rhs}`",
319 label = "no implementation for `{Self} * {Rhs}`"
320)]
321#[doc(alias = "*")]
322pub const trait Mul<Rhs = Self> {
323 #[stable(feature = "rust1", since = "1.0.0")]
325 type Output;
326
327 #[must_use = "this returns the result of the operation, without modifying the original"]
335 #[rustc_diagnostic_item = "mul"]
336 #[stable(feature = "rust1", since = "1.0.0")]
337 fn mul(self, rhs: Rhs) -> Self::Output;
338}
339
340macro_rules! mul_impl {
341 ($($t:ty)*) => ($(
342 #[stable(feature = "rust1", since = "1.0.0")]
343 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
344 const impl Mul for $t {
345 type Output = $t;
346
347 #[inline]
348 #[track_caller]
349 #[rustc_inherit_overflow_checks]
350 fn mul(self, other: $t) -> $t { self * other }
351 }
352
353 forward_ref_binop! { impl Mul, mul for $t, $t,
354 #[stable(feature = "rust1", since = "1.0.0")]
355 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
356 )*)
357}
358
359#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for usize {
type Output = usize;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: usize) -> usize { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<usize> for &usize {
type Output = <usize as Mul<usize>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: usize) -> <usize as Mul<usize>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&usize> for usize {
type Output = <usize as Mul<usize>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &usize) -> <usize as Mul<usize>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&usize> for &usize {
type Output = <usize as Mul<usize>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &usize) -> <usize as Mul<usize>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for u8 {
type Output = u8;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: u8) -> u8 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<u8> for &u8 {
type Output = <u8 as Mul<u8>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: u8) -> <u8 as Mul<u8>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u8> for u8 {
type Output = <u8 as Mul<u8>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u8) -> <u8 as Mul<u8>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u8> for &u8 {
type Output = <u8 as Mul<u8>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u8) -> <u8 as Mul<u8>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for u16 {
type Output = u16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: u16) -> u16 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<u16> for &u16 {
type Output = <u16 as Mul<u16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: u16) -> <u16 as Mul<u16>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u16> for u16 {
type Output = <u16 as Mul<u16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u16) -> <u16 as Mul<u16>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u16> for &u16 {
type Output = <u16 as Mul<u16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u16) -> <u16 as Mul<u16>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for u32 {
type Output = u32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: u32) -> u32 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<u32> for &u32 {
type Output = <u32 as Mul<u32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: u32) -> <u32 as Mul<u32>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u32> for u32 {
type Output = <u32 as Mul<u32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u32) -> <u32 as Mul<u32>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u32> for &u32 {
type Output = <u32 as Mul<u32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u32) -> <u32 as Mul<u32>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for u64 {
type Output = u64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: u64) -> u64 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<u64> for &u64 {
type Output = <u64 as Mul<u64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: u64) -> <u64 as Mul<u64>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u64> for u64 {
type Output = <u64 as Mul<u64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u64) -> <u64 as Mul<u64>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u64> for &u64 {
type Output = <u64 as Mul<u64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u64) -> <u64 as Mul<u64>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for u128 {
type Output = u128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: u128) -> u128 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<u128> for &u128 {
type Output = <u128 as Mul<u128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: u128) -> <u128 as Mul<u128>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u128> for u128 {
type Output = <u128 as Mul<u128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u128) -> <u128 as Mul<u128>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&u128> for &u128 {
type Output = <u128 as Mul<u128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &u128) -> <u128 as Mul<u128>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for isize {
type Output = isize;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: isize) -> isize { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<isize> for &isize {
type Output = <isize as Mul<isize>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: isize) -> <isize as Mul<isize>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&isize> for isize {
type Output = <isize as Mul<isize>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &isize) -> <isize as Mul<isize>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&isize> for &isize {
type Output = <isize as Mul<isize>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &isize) -> <isize as Mul<isize>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for i8 {
type Output = i8;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: i8) -> i8 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<i8> for &i8 {
type Output = <i8 as Mul<i8>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: i8) -> <i8 as Mul<i8>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i8> for i8 {
type Output = <i8 as Mul<i8>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i8) -> <i8 as Mul<i8>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i8> for &i8 {
type Output = <i8 as Mul<i8>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i8) -> <i8 as Mul<i8>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for i16 {
type Output = i16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: i16) -> i16 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<i16> for &i16 {
type Output = <i16 as Mul<i16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: i16) -> <i16 as Mul<i16>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i16> for i16 {
type Output = <i16 as Mul<i16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i16) -> <i16 as Mul<i16>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i16> for &i16 {
type Output = <i16 as Mul<i16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i16) -> <i16 as Mul<i16>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for i32 {
type Output = i32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: i32) -> i32 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<i32> for &i32 {
type Output = <i32 as Mul<i32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: i32) -> <i32 as Mul<i32>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i32> for i32 {
type Output = <i32 as Mul<i32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i32) -> <i32 as Mul<i32>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i32> for &i32 {
type Output = <i32 as Mul<i32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i32) -> <i32 as Mul<i32>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for i64 {
type Output = i64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: i64) -> i64 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<i64> for &i64 {
type Output = <i64 as Mul<i64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: i64) -> <i64 as Mul<i64>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i64> for i64 {
type Output = <i64 as Mul<i64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i64) -> <i64 as Mul<i64>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i64> for &i64 {
type Output = <i64 as Mul<i64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i64) -> <i64 as Mul<i64>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for i128 {
type Output = i128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: i128) -> i128 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<i128> for &i128 {
type Output = <i128 as Mul<i128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: i128) -> <i128 as Mul<i128>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i128> for i128 {
type Output = <i128 as Mul<i128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i128) -> <i128 as Mul<i128>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&i128> for &i128 {
type Output = <i128 as Mul<i128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &i128) -> <i128 as Mul<i128>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for f16 {
type Output = f16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: f16) -> f16 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<f16> for &f16 {
type Output = <f16 as Mul<f16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: f16) -> <f16 as Mul<f16>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&f16> for f16 {
type Output = <f16 as Mul<f16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &f16) -> <f16 as Mul<f16>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&f16> for &f16 {
type Output = <f16 as Mul<f16>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &f16) -> <f16 as Mul<f16>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for f32 {
type Output = f32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: f32) -> f32 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<f32> for &f32 {
type Output = <f32 as Mul<f32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: f32) -> <f32 as Mul<f32>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&f32> for f32 {
type Output = <f32 as Mul<f32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &f32) -> <f32 as Mul<f32>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&f32> for &f32 {
type Output = <f32 as Mul<f32>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &f32) -> <f32 as Mul<f32>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for f64 {
type Output = f64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: f64) -> f64 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<f64> for &f64 {
type Output = <f64 as Mul<f64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: f64) -> <f64 as Mul<f64>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&f64> for f64 {
type Output = <f64 as Mul<f64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &f64) -> <f64 as Mul<f64>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&f64> for &f64 {
type Output = <f64 as Mul<f64>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &f64) -> <f64 as Mul<f64>>::Output {
Mul::mul(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul for f128 {
type Output = f128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul(self, other: f128) -> f128 { self * other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<f128> for &f128 {
type Output = <f128 as Mul<f128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: f128) -> <f128 as Mul<f128>>::Output {
Mul::mul(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&f128> for f128 {
type Output = <f128 as Mul<f128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &f128) -> <f128 as Mul<f128>>::Output {
Mul::mul(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Mul<&f128> for &f128 {
type Output = <f128 as Mul<f128>>::Output;
#[inline]
#[track_caller]
fn mul(self, other: &f128) -> <f128 as Mul<f128>>::Output {
Mul::mul(*self, *other)
}
}mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
360
361#[lang = "div"]
453#[stable(feature = "rust1", since = "1.0.0")]
454#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
455#[diagnostic::on_unimplemented(
456 message = "cannot divide `{Self}` by `{Rhs}`",
457 label = "no implementation for `{Self} / {Rhs}`"
458)]
459#[doc(alias = "/")]
460pub const trait Div<Rhs = Self> {
461 #[stable(feature = "rust1", since = "1.0.0")]
463 type Output;
464
465 #[must_use = "this returns the result of the operation, without modifying the original"]
473 #[rustc_diagnostic_item = "div"]
474 #[stable(feature = "rust1", since = "1.0.0")]
475 fn div(self, rhs: Rhs) -> Self::Output;
476}
477
478macro_rules! div_impl_integer {
479 ($(($($t:ty)*) => $panic:expr),*) => ($($(
480 #[doc = $panic]
486 #[stable(feature = "rust1", since = "1.0.0")]
487 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
488 const impl Div for $t {
489 type Output = $t;
490
491 #[inline]
492 #[track_caller]
493 fn div(self, other: $t) -> $t { self / other }
494 }
495
496 forward_ref_binop! { impl Div, div for $t, $t,
497 #[stable(feature = "rust1", since = "1.0.0")]
498 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
499 )*)*)
500}
501
502#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for usize {
type Output = usize;
#[inline]
#[track_caller]
fn div(self, other: usize) -> usize { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<usize> for &usize {
type Output = <usize as Div<usize>>::Output;
#[inline]
#[track_caller]
fn div(self, other: usize) -> <usize as Div<usize>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&usize> for usize {
type Output = <usize as Div<usize>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &usize) -> <usize as Div<usize>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&usize> for &usize {
type Output = <usize as Div<usize>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &usize) -> <usize as Div<usize>>::Output {
Div::div(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for u8 {
type Output = u8;
#[inline]
#[track_caller]
fn div(self, other: u8) -> u8 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<u8> for &u8 {
type Output = <u8 as Div<u8>>::Output;
#[inline]
#[track_caller]
fn div(self, other: u8) -> <u8 as Div<u8>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u8> for u8 {
type Output = <u8 as Div<u8>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u8) -> <u8 as Div<u8>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u8> for &u8 {
type Output = <u8 as Div<u8>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u8) -> <u8 as Div<u8>>::Output {
Div::div(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for u16 {
type Output = u16;
#[inline]
#[track_caller]
fn div(self, other: u16) -> u16 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<u16> for &u16 {
type Output = <u16 as Div<u16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: u16) -> <u16 as Div<u16>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u16> for u16 {
type Output = <u16 as Div<u16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u16) -> <u16 as Div<u16>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u16> for &u16 {
type Output = <u16 as Div<u16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u16) -> <u16 as Div<u16>>::Output {
Div::div(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for u32 {
type Output = u32;
#[inline]
#[track_caller]
fn div(self, other: u32) -> u32 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<u32> for &u32 {
type Output = <u32 as Div<u32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: u32) -> <u32 as Div<u32>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u32> for u32 {
type Output = <u32 as Div<u32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u32) -> <u32 as Div<u32>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u32> for &u32 {
type Output = <u32 as Div<u32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u32) -> <u32 as Div<u32>>::Output {
Div::div(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for u64 {
type Output = u64;
#[inline]
#[track_caller]
fn div(self, other: u64) -> u64 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<u64> for &u64 {
type Output = <u64 as Div<u64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: u64) -> <u64 as Div<u64>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u64> for u64 {
type Output = <u64 as Div<u64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u64) -> <u64 as Div<u64>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u64> for &u64 {
type Output = <u64 as Div<u64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u64) -> <u64 as Div<u64>>::Output {
Div::div(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for u128 {
type Output = u128;
#[inline]
#[track_caller]
fn div(self, other: u128) -> u128 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<u128> for &u128 {
type Output = <u128 as Div<u128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: u128) -> <u128 as Div<u128>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u128> for u128 {
type Output = <u128 as Div<u128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u128) -> <u128 as Div<u128>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&u128> for &u128 {
type Output = <u128 as Div<u128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &u128) -> <u128 as Div<u128>>::Output {
Div::div(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or the division results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for isize {
type Output = isize;
#[inline]
#[track_caller]
fn div(self, other: isize) -> isize { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<isize> for &isize {
type Output = <isize as Div<isize>>::Output;
#[inline]
#[track_caller]
fn div(self, other: isize) -> <isize as Div<isize>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&isize> for isize {
type Output = <isize as Div<isize>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &isize) -> <isize as Div<isize>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&isize> for &isize {
type Output = <isize as Div<isize>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &isize) -> <isize as Div<isize>>::Output {
Div::div(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or the division results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for i8 {
type Output = i8;
#[inline]
#[track_caller]
fn div(self, other: i8) -> i8 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<i8> for &i8 {
type Output = <i8 as Div<i8>>::Output;
#[inline]
#[track_caller]
fn div(self, other: i8) -> <i8 as Div<i8>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i8> for i8 {
type Output = <i8 as Div<i8>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i8) -> <i8 as Div<i8>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i8> for &i8 {
type Output = <i8 as Div<i8>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i8) -> <i8 as Div<i8>>::Output {
Div::div(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or the division results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for i16 {
type Output = i16;
#[inline]
#[track_caller]
fn div(self, other: i16) -> i16 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<i16> for &i16 {
type Output = <i16 as Div<i16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: i16) -> <i16 as Div<i16>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i16> for i16 {
type Output = <i16 as Div<i16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i16) -> <i16 as Div<i16>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i16> for &i16 {
type Output = <i16 as Div<i16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i16) -> <i16 as Div<i16>>::Output {
Div::div(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or the division results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for i32 {
type Output = i32;
#[inline]
#[track_caller]
fn div(self, other: i32) -> i32 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<i32> for &i32 {
type Output = <i32 as Div<i32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: i32) -> <i32 as Div<i32>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i32> for i32 {
type Output = <i32 as Div<i32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i32) -> <i32 as Div<i32>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i32> for &i32 {
type Output = <i32 as Div<i32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i32) -> <i32 as Div<i32>>::Output {
Div::div(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or the division results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for i64 {
type Output = i64;
#[inline]
#[track_caller]
fn div(self, other: i64) -> i64 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<i64> for &i64 {
type Output = <i64 as Div<i64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: i64) -> <i64 as Div<i64>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i64> for i64 {
type Output = <i64 as Div<i64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i64) -> <i64 as Div<i64>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i64> for &i64 {
type Output = <i64 as Div<i64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i64) -> <i64 as Div<i64>>::Output {
Div::div(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or the division results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for i128 {
type Output = i128;
#[inline]
#[track_caller]
fn div(self, other: i128) -> i128 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<i128> for &i128 {
type Output = <i128 as Div<i128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: i128) -> <i128 as Div<i128>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i128> for i128 {
type Output = <i128 as Div<i128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i128) -> <i128 as Div<i128>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&i128> for &i128 {
type Output = <i128 as Div<i128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &i128) -> <i128 as Div<i128>>::Output {
Div::div(*self, *other)
}
}div_impl_integer! {
503 (usize u8 u16 u32 u64 u128) => "This operation will panic if `other == 0`.",
504 (isize i8 i16 i32 i64 i128) => "This operation will panic if `other == 0` or the division results in overflow."
505}
506
507macro_rules! div_impl_float {
508 ($($t:ty)*) => ($(
509 #[stable(feature = "rust1", since = "1.0.0")]
510 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
511 const impl Div for $t {
512 type Output = $t;
513
514 #[inline]
515 fn div(self, other: $t) -> $t { self / other }
516 }
517
518 forward_ref_binop! { impl Div, div for $t, $t,
519 #[stable(feature = "rust1", since = "1.0.0")]
520 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
521 )*)
522}
523
524#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for f16 {
type Output = f16;
#[inline]
fn div(self, other: f16) -> f16 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<f16> for &f16 {
type Output = <f16 as Div<f16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: f16) -> <f16 as Div<f16>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&f16> for f16 {
type Output = <f16 as Div<f16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &f16) -> <f16 as Div<f16>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&f16> for &f16 {
type Output = <f16 as Div<f16>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &f16) -> <f16 as Div<f16>>::Output {
Div::div(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for f32 {
type Output = f32;
#[inline]
fn div(self, other: f32) -> f32 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<f32> for &f32 {
type Output = <f32 as Div<f32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: f32) -> <f32 as Div<f32>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&f32> for f32 {
type Output = <f32 as Div<f32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &f32) -> <f32 as Div<f32>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&f32> for &f32 {
type Output = <f32 as Div<f32>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &f32) -> <f32 as Div<f32>>::Output {
Div::div(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for f64 {
type Output = f64;
#[inline]
fn div(self, other: f64) -> f64 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<f64> for &f64 {
type Output = <f64 as Div<f64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: f64) -> <f64 as Div<f64>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&f64> for f64 {
type Output = <f64 as Div<f64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &f64) -> <f64 as Div<f64>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&f64> for &f64 {
type Output = <f64 as Div<f64>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &f64) -> <f64 as Div<f64>>::Output {
Div::div(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div for f128 {
type Output = f128;
#[inline]
fn div(self, other: f128) -> f128 { self / other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<f128> for &f128 {
type Output = <f128 as Div<f128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: f128) -> <f128 as Div<f128>>::Output {
Div::div(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&f128> for f128 {
type Output = <f128 as Div<f128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &f128) -> <f128 as Div<f128>>::Output {
Div::div(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Div<&f128> for &f128 {
type Output = <f128 as Div<f128>>::Output;
#[inline]
#[track_caller]
fn div(self, other: &f128) -> <f128 as Div<f128>>::Output {
Div::div(*self, *other)
}
}div_impl_float! { f16 f32 f64 f128 }
525
526#[lang = "rem"]
562#[stable(feature = "rust1", since = "1.0.0")]
563#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
564#[diagnostic::on_unimplemented(
565 message = "cannot calculate the remainder of `{Self}` divided by `{Rhs}`",
566 label = "no implementation for `{Self} % {Rhs}`"
567)]
568#[doc(alias = "%")]
569pub const trait Rem<Rhs = Self> {
570 #[stable(feature = "rust1", since = "1.0.0")]
572 type Output;
573
574 #[must_use = "this returns the result of the operation, without modifying the original"]
582 #[rustc_diagnostic_item = "rem"]
583 #[stable(feature = "rust1", since = "1.0.0")]
584 fn rem(self, rhs: Rhs) -> Self::Output;
585}
586
587macro_rules! rem_impl_integer {
588 ($(($($t:ty)*) => $panic:expr),*) => ($($(
589 #[doc = $panic]
595 #[stable(feature = "rust1", since = "1.0.0")]
596 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
597 const impl Rem for $t {
598 type Output = $t;
599
600 #[inline]
601 #[track_caller]
602 fn rem(self, other: $t) -> $t { self % other }
603 }
604
605 forward_ref_binop! { impl Rem, rem for $t, $t,
606 #[stable(feature = "rust1", since = "1.0.0")]
607 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
608 )*)*)
609}
610
611#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for usize {
type Output = usize;
#[inline]
#[track_caller]
fn rem(self, other: usize) -> usize { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<usize> for &usize {
type Output = <usize as Rem<usize>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: usize) -> <usize as Rem<usize>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&usize> for usize {
type Output = <usize as Rem<usize>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &usize) -> <usize as Rem<usize>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&usize> for &usize {
type Output = <usize as Rem<usize>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &usize) -> <usize as Rem<usize>>::Output {
Rem::rem(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for u8 {
type Output = u8;
#[inline]
#[track_caller]
fn rem(self, other: u8) -> u8 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<u8> for &u8 {
type Output = <u8 as Rem<u8>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: u8) -> <u8 as Rem<u8>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u8> for u8 {
type Output = <u8 as Rem<u8>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u8) -> <u8 as Rem<u8>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u8> for &u8 {
type Output = <u8 as Rem<u8>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u8) -> <u8 as Rem<u8>>::Output {
Rem::rem(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for u16 {
type Output = u16;
#[inline]
#[track_caller]
fn rem(self, other: u16) -> u16 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<u16> for &u16 {
type Output = <u16 as Rem<u16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: u16) -> <u16 as Rem<u16>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u16> for u16 {
type Output = <u16 as Rem<u16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u16) -> <u16 as Rem<u16>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u16> for &u16 {
type Output = <u16 as Rem<u16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u16) -> <u16 as Rem<u16>>::Output {
Rem::rem(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for u32 {
type Output = u32;
#[inline]
#[track_caller]
fn rem(self, other: u32) -> u32 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<u32> for &u32 {
type Output = <u32 as Rem<u32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: u32) -> <u32 as Rem<u32>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u32> for u32 {
type Output = <u32 as Rem<u32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u32) -> <u32 as Rem<u32>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u32> for &u32 {
type Output = <u32 as Rem<u32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u32) -> <u32 as Rem<u32>>::Output {
Rem::rem(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for u64 {
type Output = u64;
#[inline]
#[track_caller]
fn rem(self, other: u64) -> u64 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<u64> for &u64 {
type Output = <u64 as Rem<u64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: u64) -> <u64 as Rem<u64>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u64> for u64 {
type Output = <u64 as Rem<u64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u64) -> <u64 as Rem<u64>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u64> for &u64 {
type Output = <u64 as Rem<u64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u64) -> <u64 as Rem<u64>>::Output {
Rem::rem(*self, *other)
}
}
#[doc = "This operation will panic if `other == 0`."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for u128 {
type Output = u128;
#[inline]
#[track_caller]
fn rem(self, other: u128) -> u128 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<u128> for &u128 {
type Output = <u128 as Rem<u128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: u128) -> <u128 as Rem<u128>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u128> for u128 {
type Output = <u128 as Rem<u128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u128) -> <u128 as Rem<u128>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&u128> for &u128 {
type Output = <u128 as Rem<u128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &u128) -> <u128 as Rem<u128>>::Output {
Rem::rem(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or if `self / other` results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for isize {
type Output = isize;
#[inline]
#[track_caller]
fn rem(self, other: isize) -> isize { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<isize> for &isize {
type Output = <isize as Rem<isize>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: isize) -> <isize as Rem<isize>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&isize> for isize {
type Output = <isize as Rem<isize>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &isize) -> <isize as Rem<isize>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&isize> for &isize {
type Output = <isize as Rem<isize>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &isize) -> <isize as Rem<isize>>::Output {
Rem::rem(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or if `self / other` results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for i8 {
type Output = i8;
#[inline]
#[track_caller]
fn rem(self, other: i8) -> i8 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<i8> for &i8 {
type Output = <i8 as Rem<i8>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: i8) -> <i8 as Rem<i8>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i8> for i8 {
type Output = <i8 as Rem<i8>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i8) -> <i8 as Rem<i8>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i8> for &i8 {
type Output = <i8 as Rem<i8>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i8) -> <i8 as Rem<i8>>::Output {
Rem::rem(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or if `self / other` results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for i16 {
type Output = i16;
#[inline]
#[track_caller]
fn rem(self, other: i16) -> i16 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<i16> for &i16 {
type Output = <i16 as Rem<i16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: i16) -> <i16 as Rem<i16>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i16> for i16 {
type Output = <i16 as Rem<i16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i16) -> <i16 as Rem<i16>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i16> for &i16 {
type Output = <i16 as Rem<i16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i16) -> <i16 as Rem<i16>>::Output {
Rem::rem(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or if `self / other` results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for i32 {
type Output = i32;
#[inline]
#[track_caller]
fn rem(self, other: i32) -> i32 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<i32> for &i32 {
type Output = <i32 as Rem<i32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: i32) -> <i32 as Rem<i32>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i32> for i32 {
type Output = <i32 as Rem<i32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i32) -> <i32 as Rem<i32>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i32> for &i32 {
type Output = <i32 as Rem<i32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i32) -> <i32 as Rem<i32>>::Output {
Rem::rem(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or if `self / other` results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for i64 {
type Output = i64;
#[inline]
#[track_caller]
fn rem(self, other: i64) -> i64 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<i64> for &i64 {
type Output = <i64 as Rem<i64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: i64) -> <i64 as Rem<i64>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i64> for i64 {
type Output = <i64 as Rem<i64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i64) -> <i64 as Rem<i64>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i64> for &i64 {
type Output = <i64 as Rem<i64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i64) -> <i64 as Rem<i64>>::Output {
Rem::rem(*self, *other)
}
}
#[doc =
"This operation will panic if `other == 0` or if `self / other` results in overflow."]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for i128 {
type Output = i128;
#[inline]
#[track_caller]
fn rem(self, other: i128) -> i128 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<i128> for &i128 {
type Output = <i128 as Rem<i128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: i128) -> <i128 as Rem<i128>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i128> for i128 {
type Output = <i128 as Rem<i128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i128) -> <i128 as Rem<i128>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&i128> for &i128 {
type Output = <i128 as Rem<i128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &i128) -> <i128 as Rem<i128>>::Output {
Rem::rem(*self, *other)
}
}rem_impl_integer! {
612 (usize u8 u16 u32 u64 u128) => "This operation will panic if `other == 0`.",
613 (isize i8 i16 i32 i64 i128) => "This operation will panic if `other == 0` or if `self / other` results in overflow."
614}
615
616macro_rules! rem_impl_float {
617 ($($t:ty)*) => ($(
618
619 #[stable(feature = "rust1", since = "1.0.0")]
634 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
635 const impl Rem for $t {
636 type Output = $t;
637
638 #[inline]
639 fn rem(self, other: $t) -> $t { self % other }
640 }
641
642 forward_ref_binop! { impl Rem, rem for $t, $t,
643 #[stable(feature = "rust1", since = "1.0.0")]
644 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
645 )*)
646}
647
648#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for f16 {
type Output = f16;
#[inline]
fn rem(self, other: f16) -> f16 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<f16> for &f16 {
type Output = <f16 as Rem<f16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: f16) -> <f16 as Rem<f16>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&f16> for f16 {
type Output = <f16 as Rem<f16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &f16) -> <f16 as Rem<f16>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&f16> for &f16 {
type Output = <f16 as Rem<f16>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &f16) -> <f16 as Rem<f16>>::Output {
Rem::rem(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for f32 {
type Output = f32;
#[inline]
fn rem(self, other: f32) -> f32 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<f32> for &f32 {
type Output = <f32 as Rem<f32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: f32) -> <f32 as Rem<f32>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&f32> for f32 {
type Output = <f32 as Rem<f32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &f32) -> <f32 as Rem<f32>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&f32> for &f32 {
type Output = <f32 as Rem<f32>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &f32) -> <f32 as Rem<f32>>::Output {
Rem::rem(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for f64 {
type Output = f64;
#[inline]
fn rem(self, other: f64) -> f64 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<f64> for &f64 {
type Output = <f64 as Rem<f64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: f64) -> <f64 as Rem<f64>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&f64> for f64 {
type Output = <f64 as Rem<f64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &f64) -> <f64 as Rem<f64>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&f64> for &f64 {
type Output = <f64 as Rem<f64>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &f64) -> <f64 as Rem<f64>>::Output {
Rem::rem(*self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem for f128 {
type Output = f128;
#[inline]
fn rem(self, other: f128) -> f128 { self % other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<f128> for &f128 {
type Output = <f128 as Rem<f128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: f128) -> <f128 as Rem<f128>>::Output {
Rem::rem(*self, other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&f128> for f128 {
type Output = <f128 as Rem<f128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &f128) -> <f128 as Rem<f128>>::Output {
Rem::rem(self, *other)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Rem<&f128> for &f128 {
type Output = <f128 as Rem<f128>>::Output;
#[inline]
#[track_caller]
fn rem(self, other: &f128) -> <f128 as Rem<f128>>::Output {
Rem::rem(*self, *other)
}
}rem_impl_float! { f16 f32 f64 f128 }
649
650#[lang = "neg"]
687#[stable(feature = "rust1", since = "1.0.0")]
688#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
689#[doc(alias = "-")]
690pub const trait Neg {
691 #[stable(feature = "rust1", since = "1.0.0")]
693 type Output;
694
695 #[must_use = "this returns the result of the operation, without modifying the original"]
704 #[rustc_diagnostic_item = "neg"]
705 #[stable(feature = "rust1", since = "1.0.0")]
706 fn neg(self) -> Self::Output;
707}
708
709macro_rules! neg_impl {
710 ($($t:ty)*) => ($(
711 #[stable(feature = "rust1", since = "1.0.0")]
712 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
713 const impl Neg for $t {
714 type Output = $t;
715
716 #[inline]
717 #[track_caller]
718 #[rustc_inherit_overflow_checks]
719 fn neg(self) -> $t { -self }
720 }
721
722 forward_ref_unop! { impl Neg, neg for $t,
723 #[stable(feature = "rust1", since = "1.0.0")]
724 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
725 )*)
726}
727
728#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for isize {
type Output = isize;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> isize { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &isize {
type Output = <isize as Neg>::Output;
#[inline]
fn neg(self) -> <isize as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for i8 {
type Output = i8;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> i8 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &i8 {
type Output = <i8 as Neg>::Output;
#[inline]
fn neg(self) -> <i8 as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for i16 {
type Output = i16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> i16 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &i16 {
type Output = <i16 as Neg>::Output;
#[inline]
fn neg(self) -> <i16 as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for i32 {
type Output = i32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> i32 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &i32 {
type Output = <i32 as Neg>::Output;
#[inline]
fn neg(self) -> <i32 as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for i64 {
type Output = i64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> i64 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &i64 {
type Output = <i64 as Neg>::Output;
#[inline]
fn neg(self) -> <i64 as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for i128 {
type Output = i128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> i128 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &i128 {
type Output = <i128 as Neg>::Output;
#[inline]
fn neg(self) -> <i128 as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for f16 {
type Output = f16;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> f16 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &f16 {
type Output = <f16 as Neg>::Output;
#[inline]
fn neg(self) -> <f16 as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for f32 {
type Output = f32;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> f32 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &f32 {
type Output = <f32 as Neg>::Output;
#[inline]
fn neg(self) -> <f32 as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for f64 {
type Output = f64;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> f64 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &f64 {
type Output = <f64 as Neg>::Output;
#[inline]
fn neg(self) -> <f64 as Neg>::Output { Neg::neg(*self) }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for f128 {
type Output = f128;
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn neg(self) -> f128 { -self }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl Neg for &f128 {
type Output = <f128 as Neg>::Output;
#[inline]
fn neg(self) -> <f128 as Neg>::Output { Neg::neg(*self) }
}neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
729
730#[lang = "add_assign"]
760#[stable(feature = "op_assign_traits", since = "1.8.0")]
761#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
762#[diagnostic::on_unimplemented(
763 message = "cannot add-assign `{Rhs}` to `{Self}`",
764 label = "no implementation for `{Self} += {Rhs}`"
765)]
766#[doc(alias = "+")]
767#[doc(alias = "+=")]
768pub const trait AddAssign<Rhs = Self> {
769 #[stable(feature = "op_assign_traits", since = "1.8.0")]
779 fn add_assign(&mut self, rhs: Rhs);
780}
781
782macro_rules! add_assign_impl {
783 ($($t:ty)+) => ($(
784 #[stable(feature = "op_assign_traits", since = "1.8.0")]
785 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
786 const impl AddAssign for $t {
787 #[inline]
788 #[track_caller]
789 #[rustc_inherit_overflow_checks]
790 fn add_assign(&mut self, other: $t) { *self += other }
791 }
792
793 forward_ref_op_assign! { impl AddAssign, add_assign for $t, $t,
794 #[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
795 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
796 )+)
797}
798
799#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for usize {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: usize) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&usize> for usize {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &usize) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for u8 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: u8) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&u8> for u8 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &u8) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for u16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: u16) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&u16> for u16 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &u16) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for u32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: u32) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&u32> for u32 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &u32) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for u64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: u64) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&u64> for u64 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &u64) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for u128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: u128) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&u128> for u128 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &u128) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for isize {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: isize) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&isize> for isize {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &isize) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for i8 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: i8) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&i8> for i8 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &i8) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for i16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: i16) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&i16> for i16 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &i16) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for i32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: i32) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&i32> for i32 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &i32) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for i64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: i64) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&i64> for i64 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &i64) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for i128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: i128) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&i128> for i128 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &i128) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for f16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: f16) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&f16> for f16 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &f16) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for f32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: f32) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&f32> for f32 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &f32) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for f64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: f64) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&f64> for f64 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &f64) {
AddAssign::add_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign for f128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: f128) { *self += other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl AddAssign<&f128> for f128 {
#[inline]
#[track_caller]
fn add_assign(&mut self, other: &f128) {
AddAssign::add_assign(self, *other);
}
}add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
800
801#[lang = "sub_assign"]
831#[stable(feature = "op_assign_traits", since = "1.8.0")]
832#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
833#[diagnostic::on_unimplemented(
834 message = "cannot subtract-assign `{Rhs}` from `{Self}`",
835 label = "no implementation for `{Self} -= {Rhs}`"
836)]
837#[doc(alias = "-")]
838#[doc(alias = "-=")]
839pub const trait SubAssign<Rhs = Self> {
840 #[stable(feature = "op_assign_traits", since = "1.8.0")]
850 fn sub_assign(&mut self, rhs: Rhs);
851}
852
853macro_rules! sub_assign_impl {
854 ($($t:ty)+) => ($(
855 #[stable(feature = "op_assign_traits", since = "1.8.0")]
856 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
857 const impl SubAssign for $t {
858 #[inline]
859 #[track_caller]
860 #[rustc_inherit_overflow_checks]
861 fn sub_assign(&mut self, other: $t) { *self -= other }
862 }
863
864 forward_ref_op_assign! { impl SubAssign, sub_assign for $t, $t,
865 #[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
866 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
867 )+)
868}
869
870#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for usize {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: usize) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&usize> for usize {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &usize) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for u8 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: u8) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&u8> for u8 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &u8) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for u16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: u16) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&u16> for u16 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &u16) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for u32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: u32) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&u32> for u32 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &u32) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for u64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: u64) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&u64> for u64 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &u64) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for u128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: u128) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&u128> for u128 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &u128) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for isize {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: isize) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&isize> for isize {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &isize) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for i8 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: i8) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&i8> for i8 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &i8) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for i16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: i16) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&i16> for i16 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &i16) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for i32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: i32) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&i32> for i32 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &i32) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for i64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: i64) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&i64> for i64 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &i64) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for i128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: i128) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&i128> for i128 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &i128) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for f16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: f16) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&f16> for f16 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &f16) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for f32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: f32) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&f32> for f32 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &f32) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for f64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: f64) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&f64> for f64 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &f64) {
SubAssign::sub_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign for f128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: f128) { *self -= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl SubAssign<&f128> for f128 {
#[inline]
#[track_caller]
fn sub_assign(&mut self, other: &f128) {
SubAssign::sub_assign(self, *other);
}
}sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
871
872#[lang = "mul_assign"]
893#[stable(feature = "op_assign_traits", since = "1.8.0")]
894#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
895#[diagnostic::on_unimplemented(
896 message = "cannot multiply-assign `{Self}` by `{Rhs}`",
897 label = "no implementation for `{Self} *= {Rhs}`"
898)]
899#[doc(alias = "*")]
900#[doc(alias = "*=")]
901pub const trait MulAssign<Rhs = Self> {
902 #[stable(feature = "op_assign_traits", since = "1.8.0")]
912 fn mul_assign(&mut self, rhs: Rhs);
913}
914
915macro_rules! mul_assign_impl {
916 ($($t:ty)+) => ($(
917 #[stable(feature = "op_assign_traits", since = "1.8.0")]
918 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
919 const impl MulAssign for $t {
920 #[inline]
921 #[track_caller]
922 #[rustc_inherit_overflow_checks]
923 fn mul_assign(&mut self, other: $t) { *self *= other }
924 }
925
926 forward_ref_op_assign! { impl MulAssign, mul_assign for $t, $t,
927 #[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
928 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
929 )+)
930}
931
932#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for usize {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: usize) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&usize> for usize {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &usize) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for u8 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: u8) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&u8> for u8 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &u8) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for u16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: u16) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&u16> for u16 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &u16) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for u32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: u32) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&u32> for u32 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &u32) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for u64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: u64) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&u64> for u64 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &u64) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for u128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: u128) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&u128> for u128 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &u128) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for isize {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: isize) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&isize> for isize {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &isize) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for i8 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: i8) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&i8> for i8 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &i8) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for i16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: i16) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&i16> for i16 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &i16) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for i32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: i32) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&i32> for i32 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &i32) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for i64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: i64) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&i64> for i64 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &i64) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for i128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: i128) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&i128> for i128 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &i128) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for f16 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: f16) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&f16> for f16 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &f16) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for f32 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: f32) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&f32> for f32 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &f32) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for f64 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: f64) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&f64> for f64 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &f64) {
MulAssign::mul_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign for f128 {
#[inline]
#[track_caller]
#[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: f128) { *self *= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl MulAssign<&f128> for f128 {
#[inline]
#[track_caller]
fn mul_assign(&mut self, other: &f128) {
MulAssign::mul_assign(self, *other);
}
}mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
933
934#[lang = "div_assign"]
955#[stable(feature = "op_assign_traits", since = "1.8.0")]
956#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
957#[diagnostic::on_unimplemented(
958 message = "cannot divide-assign `{Self}` by `{Rhs}`",
959 label = "no implementation for `{Self} /= {Rhs}`"
960)]
961#[doc(alias = "/")]
962#[doc(alias = "/=")]
963pub const trait DivAssign<Rhs = Self> {
964 #[stable(feature = "op_assign_traits", since = "1.8.0")]
974 fn div_assign(&mut self, rhs: Rhs);
975}
976
977macro_rules! div_assign_impl {
978 ($($t:ty)+) => ($(
979 #[stable(feature = "op_assign_traits", since = "1.8.0")]
980 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
981 const impl DivAssign for $t {
982 #[inline]
983 #[track_caller]
984 fn div_assign(&mut self, other: $t) { *self /= other }
985 }
986
987 forward_ref_op_assign! { impl DivAssign, div_assign for $t, $t,
988 #[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
989 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
990 )+)
991}
992
993#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for usize {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: usize) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&usize> for usize {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &usize) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for u8 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: u8) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&u8> for u8 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &u8) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for u16 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: u16) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&u16> for u16 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &u16) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for u32 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: u32) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&u32> for u32 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &u32) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for u64 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: u64) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&u64> for u64 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &u64) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for u128 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: u128) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&u128> for u128 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &u128) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for isize {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: isize) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&isize> for isize {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &isize) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for i8 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: i8) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&i8> for i8 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &i8) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for i16 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: i16) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&i16> for i16 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &i16) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for i32 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: i32) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&i32> for i32 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &i32) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for i64 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: i64) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&i64> for i64 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &i64) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for i128 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: i128) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&i128> for i128 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &i128) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for f16 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: f16) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&f16> for f16 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &f16) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for f32 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: f32) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&f32> for f32 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &f32) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for f64 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: f64) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&f64> for f64 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &f64) {
DivAssign::div_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign for f128 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: f128) { *self /= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl DivAssign<&f128> for f128 {
#[inline]
#[track_caller]
fn div_assign(&mut self, other: &f128) {
DivAssign::div_assign(self, *other);
}
}div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
994
995#[lang = "rem_assign"]
1020#[stable(feature = "op_assign_traits", since = "1.8.0")]
1021#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
1022#[diagnostic::on_unimplemented(
1023 message = "cannot calculate and assign the remainder of `{Self}` divided by `{Rhs}`",
1024 label = "no implementation for `{Self} %= {Rhs}`"
1025)]
1026#[doc(alias = "%")]
1027#[doc(alias = "%=")]
1028pub const trait RemAssign<Rhs = Self> {
1029 #[stable(feature = "op_assign_traits", since = "1.8.0")]
1039 fn rem_assign(&mut self, rhs: Rhs);
1040}
1041
1042macro_rules! rem_assign_impl {
1043 ($($t:ty)+) => ($(
1044 #[stable(feature = "op_assign_traits", since = "1.8.0")]
1045 #[rustc_const_unstable(feature = "const_ops", issue = "143802")]
1046 const impl RemAssign for $t {
1047 #[inline]
1048 #[track_caller]
1049 fn rem_assign(&mut self, other: $t) { *self %= other }
1050 }
1051
1052 forward_ref_op_assign! { impl RemAssign, rem_assign for $t, $t,
1053 #[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
1054 #[rustc_const_unstable(feature = "const_ops", issue = "143802")] }
1055 )+)
1056}
1057
1058#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for usize {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: usize) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&usize> for usize {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &usize) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for u8 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: u8) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&u8> for u8 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &u8) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for u16 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: u16) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&u16> for u16 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &u16) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for u32 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: u32) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&u32> for u32 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &u32) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for u64 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: u64) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&u64> for u64 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &u64) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for u128 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: u128) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&u128> for u128 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &u128) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for isize {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: isize) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&isize> for isize {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &isize) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for i8 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: i8) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&i8> for i8 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &i8) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for i16 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: i16) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&i16> for i16 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &i16) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for i32 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: i32) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&i32> for i32 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &i32) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for i64 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: i64) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&i64> for i64 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &i64) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for i128 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: i128) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&i128> for i128 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &i128) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for f16 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: f16) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&f16> for f16 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &f16) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for f32 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: f32) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&f32> for f32 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &f32) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for f64 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: f64) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&f64> for f64 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &f64) {
RemAssign::rem_assign(self, *other);
}
}
#[stable(feature = "op_assign_traits", since = "1.8.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign for f128 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: f128) { *self %= other }
}
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
const impl RemAssign<&f128> for f128 {
#[inline]
#[track_caller]
fn rem_assign(&mut self, other: &f128) {
RemAssign::rem_assign(self, *other);
}
}rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }