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 impl const 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")]
impl const 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")]
impl const 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")]
impl const 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 impl const 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")]
impl const 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")]
impl const 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")]
impl const 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 impl const 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")]
impl const 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")]
impl const 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")]
impl const 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 impl const 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#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const 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")]
impl const 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")]
impl const 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 impl const 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")]
impl const 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")]
impl const 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")]
impl const 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 impl const 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#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const 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")]
impl const 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")]
impl const 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 impl const 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")]
impl const 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")]
impl const 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")]
impl const 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 impl const 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")]
impl const 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 impl const 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_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const 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 impl const 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_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const 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 impl const 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_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const 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 impl const 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_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const 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 impl const 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_builtins_by_ref", since = "1.22.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
impl const 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 }