1#![stable(feature = "rust1", since = "1.0.0")]
27
28mod bytewise;
29mod clamp;
30pub(crate) use bytewise::BytewiseEq;
31#[unstable(feature = "clamp_bounds", issue = "147781")]
32pub use clamp::ClampBounds;
33
34use self::Ordering::*;
35use crate::marker::{Destruct, PointeeSized};
36use crate::ops::ControlFlow;
37
38#[lang = "eq"]
244#[stable(feature = "rust1", since = "1.0.0")]
245#[doc(alias = "==")]
246#[doc(alias = "!=")]
247#[diagnostic::on_unimplemented(
248 message = "can't compare `{Self}` with `{Rhs}`",
249 label = "no implementation for `{Self} == {Rhs}`"
250)]
251#[rustc_diagnostic_item = "PartialEq"]
252#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
253pub const trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
254 #[must_use]
259 #[stable(feature = "rust1", since = "1.0.0")]
260 #[rustc_diagnostic_item = "cmp_partialeq_eq"]
261 fn eq(&self, other: &Rhs) -> bool;
262
263 #[inline]
275 #[must_use]
276 #[stable(feature = "rust1", since = "1.0.0")]
277 #[rustc_diagnostic_item = "cmp_partialeq_ne"]
278 fn ne(&self, other: &Rhs) -> bool {
279 !self.eq(other)
280 }
281}
282
283#[rustc_builtin_macro]
286#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
287#[allow_internal_unstable(core_intrinsics, structural_match)]
288pub macro PartialEq($item:item) {
289 }
291
292#[doc(alias = "==")]
349#[doc(alias = "!=")]
350#[stable(feature = "rust1", since = "1.0.0")]
351#[rustc_diagnostic_item = "Eq"]
352#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
353pub const trait Eq: [const] PartialEq<Self> + PointeeSized {
354 #[doc(hidden)]
359 #[coverage(off)]
360 #[inline]
361 #[stable(feature = "rust1", since = "1.0.0")]
362 #[rustc_diagnostic_item = "assert_receiver_is_total_eq"]
363 #[deprecated(since = "1.95.0", note = "implementation detail of `#[derive(Eq)]`")]
364 fn assert_receiver_is_total_eq(&self) {}
365
366 #[doc(hidden)]
369 #[coverage(off)]
370 #[unstable(feature = "derive_eq_internals", issue = "none")]
371 fn assert_fields_are_eq(&self) {}
372}
373
374#[rustc_builtin_macro]
377#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
378#[allow_internal_unstable(core_intrinsics, derive_eq_internals, structural_match)]
379#[allow_internal_unstable(coverage_attribute)]
380pub macro Eq($item:item) {
381 }
383
384#[doc(hidden)]
389#[allow(missing_debug_implementations)]
390#[unstable(
391 feature = "derive_eq_internals",
392 reason = "deriving hack, should not be public",
393 issue = "none"
394)]
395pub struct AssertParamIsEq<T: Eq + PointeeSized> {
396 _field: crate::marker::PhantomData<T>,
397}
398
399#[derive(#[automatically_derived]
#[stable(feature = "rust1", since = "1.0.0")]
impl crate::marker::Copy for Ordering { }Copy, #[automatically_derived]
#[stable(feature = "rust1", since = "1.0.0")]
impl crate::fmt::Debug for Ordering {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::write_str(f,
match self {
Ordering::Less => "Less",
Ordering::Equal => "Equal",
Ordering::Greater => "Greater",
})
}
}Debug, #[automatically_derived]
#[stable(feature = "rust1", since = "1.0.0")]
impl crate::hash::Hash for Ordering {
#[inline]
fn hash<__H: crate::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = crate::intrinsics::discriminant_value(self);
crate::hash::Hash::hash(&__self_discr, state)
}
}Hash)]
413#[derive_const(#[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[doc(hidden)]
#[stable(feature = "rust1", since = "1.0.0")]
const unsafe impl crate::clone::TrivialClone for Ordering { }
#[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[stable(feature = "rust1", since = "1.0.0")]
const impl crate::clone::Clone for Ordering {
#[inline]
fn clone(&self) -> Ordering { *self }
}Clone, #[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[stable(feature = "rust1", since = "1.0.0")]
const impl crate::cmp::Eq for Ordering {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[stable(feature = "rust1", since = "1.0.0")]
const impl crate::cmp::PartialOrd for Ordering {
#[inline]
fn partial_cmp(&self, other: &Ordering)
-> crate::option::Option<crate::cmp::Ordering> {
crate::option::Option::Some(crate::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[stable(feature = "rust1", since = "1.0.0")]
const impl crate::cmp::Ord for Ordering {
#[inline]
fn cmp(&self, other: &Ordering) -> crate::cmp::Ordering {
let __self_discr = crate::intrinsics::discriminant_value(self);
let __arg1_discr = crate::intrinsics::discriminant_value(other);
crate::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
}
}Ord, #[automatically_derived]
#[stable(feature = "rust1", since = "1.0.0")]
impl crate::marker::StructuralPartialEq for Ordering { }
#[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[stable(feature = "rust1", since = "1.0.0")]
const impl crate::cmp::PartialEq for Ordering {
#[inline]
fn eq(&self, other: &Ordering) -> bool {
let __self_discr = crate::intrinsics::discriminant_value(self);
let __arg1_discr = crate::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq)]
414#[stable(feature = "rust1", since = "1.0.0")]
415#[lang = "Ordering"]
419#[repr(i8)]
420pub enum Ordering {
421 #[stable(feature = "rust1", since = "1.0.0")]
423 Less = -1,
424 #[stable(feature = "rust1", since = "1.0.0")]
426 Equal = 0,
427 #[stable(feature = "rust1", since = "1.0.0")]
429 Greater = 1,
430}
431
432impl Ordering {
433 #[inline]
434 const fn as_raw(self) -> i8 {
435 crate::intrinsics::discriminant_value(&self)
437 }
438
439 #[inline]
451 #[must_use]
452 #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")]
453 #[stable(feature = "ordering_helpers", since = "1.53.0")]
454 pub const fn is_eq(self) -> bool {
455 self.as_raw() == 0
460 }
461
462 #[inline]
474 #[must_use]
475 #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")]
476 #[stable(feature = "ordering_helpers", since = "1.53.0")]
477 pub const fn is_ne(self) -> bool {
478 self.as_raw() != 0
479 }
480
481 #[inline]
493 #[must_use]
494 #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")]
495 #[stable(feature = "ordering_helpers", since = "1.53.0")]
496 pub const fn is_lt(self) -> bool {
497 self.as_raw() < 0
498 }
499
500 #[inline]
512 #[must_use]
513 #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")]
514 #[stable(feature = "ordering_helpers", since = "1.53.0")]
515 pub const fn is_gt(self) -> bool {
516 self.as_raw() > 0
517 }
518
519 #[inline]
531 #[must_use]
532 #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")]
533 #[stable(feature = "ordering_helpers", since = "1.53.0")]
534 pub const fn is_le(self) -> bool {
535 self.as_raw() <= 0
536 }
537
538 #[inline]
550 #[must_use]
551 #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")]
552 #[stable(feature = "ordering_helpers", since = "1.53.0")]
553 pub const fn is_ge(self) -> bool {
554 self.as_raw() >= 0
555 }
556
557 #[inline]
587 #[must_use]
588 #[rustc_const_stable(feature = "const_ordering", since = "1.48.0")]
589 #[stable(feature = "rust1", since = "1.0.0")]
590 pub const fn reverse(self) -> Ordering {
591 match self {
592 Less => Greater,
593 Equal => Equal,
594 Greater => Less,
595 }
596 }
597
598 #[inline]
626 #[must_use]
627 #[rustc_const_stable(feature = "const_ordering", since = "1.48.0")]
628 #[stable(feature = "ordering_chaining", since = "1.17.0")]
629 pub const fn then(self, other: Ordering) -> Ordering {
630 match self {
631 Equal => other,
632 _ => self,
633 }
634 }
635
636 #[inline]
665 #[must_use]
666 #[stable(feature = "ordering_chaining", since = "1.17.0")]
667 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
668 pub const fn then_with<F>(self, f: F) -> Ordering
669 where
670 F: [const] FnOnce() -> Ordering + [const] Destruct,
671 {
672 match self {
673 Equal => f(),
674 _ => self,
675 }
676 }
677}
678
679#[derive(#[automatically_derived]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
impl<T: crate::marker::Copy> crate::marker::Copy for Reverse<T> { }Copy, #[automatically_derived]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
impl<T: crate::fmt::Debug> crate::fmt::Debug for Reverse<T> {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Reverse",
&&self.0)
}
}Debug, #[automatically_derived]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
impl<T: crate::hash::Hash> crate::hash::Hash for Reverse<T> {
#[inline]
fn hash<__H: crate::hash::Hasher>(&self, state: &mut __H) {
crate::hash::Hash::hash(&self.0, state)
}
}Hash)]
696#[derive_const(#[automatically_derived]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
impl<T: crate::cmp::PartialEq> crate::marker::StructuralPartialEq for
Reverse<T> {
}
#[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
const impl<T: [const] crate::cmp::PartialEq> crate::cmp::PartialEq for
Reverse<T> {
#[inline]
fn eq(&self, other: &Reverse<T>) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
const impl<T: [const] crate::cmp::Eq> crate::cmp::Eq for Reverse<T> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) { let _: crate::cmp::AssertParamIsEq<T>; }
}Eq, #[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
const impl<T: [const] crate::default::Default> crate::default::Default for
Reverse<T> {
#[inline]
fn default() -> Reverse<T> { Reverse(crate::default::Default::default()) }
}Default)]
697#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
698#[repr(transparent)]
699pub struct Reverse<T>(#[stable(feature = "reverse_cmp_key", since = "1.19.0")] pub T);
700
701#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
702#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
703const impl<T: [const] PartialOrd> PartialOrd for Reverse<T> {
704 #[inline]
705 fn partial_cmp(&self, other: &Reverse<T>) -> Option<Ordering> {
706 other.0.partial_cmp(&self.0)
707 }
708
709 #[inline]
710 fn lt(&self, other: &Self) -> bool {
711 other.0 < self.0
712 }
713 #[inline]
714 fn le(&self, other: &Self) -> bool {
715 other.0 <= self.0
716 }
717 #[inline]
718 fn gt(&self, other: &Self) -> bool {
719 other.0 > self.0
720 }
721 #[inline]
722 fn ge(&self, other: &Self) -> bool {
723 other.0 >= self.0
724 }
725}
726
727#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
728#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
729const impl<T: [const] Ord> Ord for Reverse<T> {
730 #[inline]
731 fn cmp(&self, other: &Reverse<T>) -> Ordering {
732 other.0.cmp(&self.0)
733 }
734}
735
736#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
737impl<T: Clone> Clone for Reverse<T> {
738 #[inline]
739 fn clone(&self) -> Reverse<T> {
740 Reverse(self.0.clone())
741 }
742
743 #[inline]
744 fn clone_from(&mut self, source: &Self) {
745 self.0.clone_from(&source.0)
746 }
747}
748
749#[derive(#[automatically_derived]
impl<K: crate::fmt::Debug, V: crate::fmt::Debug> crate::fmt::Debug for
KeyAndValue<K, V> {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field2_finish(f, "KeyAndValue",
"key", &self.key, "value", &&self.value)
}
}Debug, #[automatically_derived]
impl<K: crate::marker::Copy, V: crate::marker::Copy> crate::marker::Copy for
KeyAndValue<K, V> {
}Copy, #[automatically_derived]
impl<K: crate::clone::Clone, V: crate::clone::Clone> crate::clone::Clone for
KeyAndValue<K, V> {
#[inline]
fn clone(&self) -> KeyAndValue<K, V> {
KeyAndValue {
key: crate::clone::Clone::clone(&self.key),
value: crate::clone::Clone::clone(&self.value),
}
}
}Clone)]
753pub(crate) struct KeyAndValue<K, V> {
754 pub key: K,
755 pub value: V,
756}
757impl<K: PartialEq, V> PartialEq for KeyAndValue<K, V> {
758 #[inline]
759 fn eq(&self, other: &Self) -> bool {
760 self.key == other.key
761 }
762 #[inline]
763 fn ne(&self, other: &Self) -> bool {
764 self.key != other.key
765 }
766}
767impl<K: Eq, V> Eq for KeyAndValue<K, V> {}
768impl<K: PartialOrd, V> PartialOrd for KeyAndValue<K, V> {
769 #[inline]
770 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
771 PartialOrd::partial_cmp(&self.key, &other.key)
772 }
773 #[inline]
774 fn lt(&self, other: &Self) -> bool {
775 self.key < other.key
776 }
777 #[inline]
778 fn le(&self, other: &Self) -> bool {
779 self.key <= other.key
780 }
781 #[inline]
782 fn gt(&self, other: &Self) -> bool {
783 self.key > other.key
784 }
785 #[inline]
786 fn ge(&self, other: &Self) -> bool {
787 self.key >= other.key
788 }
789}
790impl<K: Ord, V> Ord for KeyAndValue<K, V> {
791 #[inline]
792 fn cmp(&self, other: &Self) -> Ordering {
793 Ord::cmp(&self.key, &other.key)
794 }
795}
796
797#[doc(alias = "<")]
1039#[doc(alias = ">")]
1040#[doc(alias = "<=")]
1041#[doc(alias = ">=")]
1042#[stable(feature = "rust1", since = "1.0.0")]
1043#[rustc_diagnostic_item = "Ord"]
1044#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1045pub const trait Ord: [const] Eq + [const] PartialOrd<Self> + PointeeSized {
1046 #[must_use]
1061 #[stable(feature = "rust1", since = "1.0.0")]
1062 #[rustc_diagnostic_item = "ord_cmp_method"]
1063 fn cmp(&self, other: &Self) -> Ordering;
1064
1065 #[stable(feature = "ord_max_min", since = "1.21.0")]
1094 #[inline]
1095 #[must_use]
1096 #[rustc_diagnostic_item = "cmp_ord_max"]
1097 fn max(self, other: Self) -> Self
1098 where
1099 Self: Sized + [const] Destruct,
1100 {
1101 if other < self { self } else { other }
1102 }
1103
1104 #[stable(feature = "ord_max_min", since = "1.21.0")]
1133 #[inline]
1134 #[must_use]
1135 #[rustc_diagnostic_item = "cmp_ord_min"]
1136 fn min(self, other: Self) -> Self
1137 where
1138 Self: Sized + [const] Destruct,
1139 {
1140 if other < self { other } else { self }
1141 }
1142
1143 #[must_use]
1160 #[inline]
1161 #[stable(feature = "clamp", since = "1.50.0")]
1162 fn clamp(self, min: Self, max: Self) -> Self
1163 where
1164 Self: Sized + [const] Destruct,
1165 {
1166 if !(min <= max) { crate::panicking::panic("assertion failed: min <= max") };assert!(min <= max);
1167 if self < min {
1168 min
1169 } else if self > max {
1170 max
1171 } else {
1172 self
1173 }
1174 }
1175
1176 #[must_use]
1195 #[inline]
1196 #[unstable(feature = "clamp_to", issue = "147781")]
1197 fn clamp_to<R>(self, range: R) -> Self
1198 where
1199 Self: Sized + [const] Destruct,
1200 R: [const] ClampBounds<Self>,
1201 {
1202 range.clamp(self)
1203 }
1204}
1205
1206#[rustc_builtin_macro]
1209#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
1210#[allow_internal_unstable(core_intrinsics)]
1211pub macro Ord($item:item) {
1212 }
1214
1215#[lang = "partial_ord"]
1446#[stable(feature = "rust1", since = "1.0.0")]
1447#[doc(alias = ">")]
1448#[doc(alias = "<")]
1449#[doc(alias = "<=")]
1450#[doc(alias = ">=")]
1451#[diagnostic::on_unimplemented(
1452 message = "can't compare `{Self}` with `{Rhs}`",
1453 label = "no implementation for `{Self} < {Rhs}` and `{Self} > {Rhs}`"
1454)]
1455#[rustc_diagnostic_item = "PartialOrd"]
1456#[allow(multiple_supertrait_upcastable)] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1458pub const trait PartialOrd<Rhs: PointeeSized = Self>:
1459 [const] PartialEq<Rhs> + PointeeSized
1460{
1461 #[must_use]
1485 #[stable(feature = "rust1", since = "1.0.0")]
1486 #[rustc_diagnostic_item = "cmp_partialord_cmp"]
1487 fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
1488
1489 #[inline]
1499 #[must_use]
1500 #[stable(feature = "rust1", since = "1.0.0")]
1501 #[rustc_diagnostic_item = "cmp_partialord_lt"]
1502 fn lt(&self, other: &Rhs) -> bool {
1503 self.partial_cmp(other).is_some_and(Ordering::is_lt)
1504 }
1505
1506 #[inline]
1517 #[must_use]
1518 #[stable(feature = "rust1", since = "1.0.0")]
1519 #[rustc_diagnostic_item = "cmp_partialord_le"]
1520 fn le(&self, other: &Rhs) -> bool {
1521 self.partial_cmp(other).is_some_and(Ordering::is_le)
1522 }
1523
1524 #[inline]
1535 #[must_use]
1536 #[stable(feature = "rust1", since = "1.0.0")]
1537 #[rustc_diagnostic_item = "cmp_partialord_gt"]
1538 fn gt(&self, other: &Rhs) -> bool {
1539 self.partial_cmp(other).is_some_and(Ordering::is_gt)
1540 }
1541
1542 #[inline]
1553 #[must_use]
1554 #[stable(feature = "rust1", since = "1.0.0")]
1555 #[rustc_diagnostic_item = "cmp_partialord_ge"]
1556 fn ge(&self, other: &Rhs) -> bool {
1557 self.partial_cmp(other).is_some_and(Ordering::is_ge)
1558 }
1559
1560 #[inline]
1568 #[unstable(feature = "partial_ord_chaining_methods", issue = "none")]
1570 #[doc(hidden)]
1571 fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool> {
1572 default_chaining_impl(self, other, Ordering::is_lt)
1573 }
1574
1575 #[inline]
1577 #[unstable(feature = "partial_ord_chaining_methods", issue = "none")]
1578 #[doc(hidden)]
1579 fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool> {
1580 default_chaining_impl(self, other, Ordering::is_le)
1581 }
1582
1583 #[inline]
1585 #[unstable(feature = "partial_ord_chaining_methods", issue = "none")]
1586 #[doc(hidden)]
1587 fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool> {
1588 default_chaining_impl(self, other, Ordering::is_gt)
1589 }
1590
1591 #[inline]
1593 #[unstable(feature = "partial_ord_chaining_methods", issue = "none")]
1594 #[doc(hidden)]
1595 fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool> {
1596 default_chaining_impl(self, other, Ordering::is_ge)
1597 }
1598}
1599
1600#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1601const fn default_chaining_impl<T, U>(
1602 lhs: &T,
1603 rhs: &U,
1604 p: impl [const] FnOnce(Ordering) -> bool + [const] Destruct,
1605) -> ControlFlow<bool>
1606where
1607 T: [const] PartialOrd<U> + PointeeSized,
1608 U: PointeeSized,
1609{
1610 match <T as PartialOrd<U>>::partial_cmp(lhs, rhs) {
1614 Some(Equal) => ControlFlow::Continue(()),
1615 Some(c) => ControlFlow::Break(p(c)),
1616 None => ControlFlow::Break(false),
1617 }
1618}
1619
1620#[rustc_builtin_macro]
1623#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
1624#[allow_internal_unstable(core_intrinsics)]
1625pub macro PartialOrd($item:item) {
1626 }
1628
1629#[inline]
1662#[must_use]
1663#[stable(feature = "rust1", since = "1.0.0")]
1664#[rustc_diagnostic_item = "cmp_min"]
1665#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1666pub const fn min<T: [const] Ord + [const] Destruct>(v1: T, v2: T) -> T {
1667 v1.min(v2)
1668}
1669
1670#[inline]
1694#[must_use]
1695#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
1696#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1697pub const fn min_by<T: [const] Destruct, F: [const] FnOnce(&T, &T) -> Ordering>(
1698 v1: T,
1699 v2: T,
1700 compare: F,
1701) -> T {
1702 if compare(&v1, &v2).is_le() { v1 } else { v2 }
1703}
1704
1705#[inline]
1724#[must_use]
1725#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
1726#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1727pub const fn min_by_key<T, F, K>(v1: T, v2: T, mut f: F) -> T
1728where
1729 T: [const] Destruct,
1730 F: [const] FnMut(&T) -> K + [const] Destruct,
1731 K: [const] Ord + [const] Destruct,
1732{
1733 if f(&v2) < f(&v1) { v2 } else { v1 }
1734}
1735
1736#[inline]
1769#[must_use]
1770#[stable(feature = "rust1", since = "1.0.0")]
1771#[rustc_diagnostic_item = "cmp_max"]
1772#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1773pub const fn max<T: [const] Ord + [const] Destruct>(v1: T, v2: T) -> T {
1774 v1.max(v2)
1775}
1776
1777#[inline]
1801#[must_use]
1802#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
1803#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1804pub const fn max_by<T: [const] Destruct, F: [const] FnOnce(&T, &T) -> Ordering>(
1805 v1: T,
1806 v2: T,
1807 compare: F,
1808) -> T {
1809 if compare(&v1, &v2).is_gt() { v1 } else { v2 }
1810}
1811
1812#[inline]
1831#[must_use]
1832#[stable(feature = "cmp_min_max_by", since = "1.53.0")]
1833#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1834pub const fn max_by_key<T, F, K>(v1: T, v2: T, mut f: F) -> T
1835where
1836 T: [const] Destruct,
1837 F: [const] FnMut(&T) -> K + [const] Destruct,
1838 K: [const] Ord + [const] Destruct,
1839{
1840 if f(&v2) < f(&v1) { v1 } else { v2 }
1841}
1842
1843#[inline]
1881#[must_use]
1882#[unstable(feature = "cmp_minmax", issue = "115939")]
1883#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1884pub const fn minmax<T>(v1: T, v2: T) -> [T; 2]
1885where
1886 T: [const] Ord,
1887{
1888 if v2 < v1 { [v2, v1] } else { [v1, v2] }
1889}
1890
1891#[inline]
1916#[must_use]
1917#[unstable(feature = "cmp_minmax", issue = "115939")]
1918#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1919pub const fn minmax_by<T, F>(v1: T, v2: T, compare: F) -> [T; 2]
1920where
1921 F: [const] FnOnce(&T, &T) -> Ordering,
1922{
1923 if compare(&v1, &v2).is_le() { [v1, v2] } else { [v2, v1] }
1924}
1925
1926#[inline]
1945#[must_use]
1946#[unstable(feature = "cmp_minmax", issue = "115939")]
1947#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1948pub const fn minmax_by_key<T, F, K>(v1: T, v2: T, mut f: F) -> [T; 2]
1949where
1950 F: [const] FnMut(&T) -> K + [const] Destruct,
1951 K: [const] Ord + [const] Destruct,
1952{
1953 if f(&v2) < f(&v1) { [v2, v1] } else { [v1, v2] }
1954}
1955
1956macro impl_for_tuples_up_to($mac:ident! { $($x:ident, $($y:ident,)*)? }) {
1958 $(impl_for_tuples_up_to! {
1959 $mac! { $($y,)* }
1960 })?
1961 $mac! { $($x, $($y,)*)? }
1962}
1963
1964macro impl_tuples($($mac:ident,)+) {
1966 $(impl_for_tuples_up_to! { $mac! { x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, } })+
1967}
1968
1969#[diagnostic::on_unimplemented(message = "`{Self}` is not a homogeneous tuple")]
1972#[unstable(feature = "cmp_splat_internals", issue = "160728")]
1973#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
1974const trait HomogeneousTuple: crate::marker::Tuple {
1975 type Item;
1977}
1978
1979macro impl_homogeneous_tuple($($($x:ident,)+)?) {
1981 $(
1982 #[unstable(feature = "cmp_splat_internals", issue = "160728")]
1983 #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
1984 const impl<T> HomogeneousTuple for ($(${ignore($x)}T,)+) {
1985 type Item = T;
1986 }
1987 )?
1988}
1989
1990#[unstable(feature = "cmp_splat_internals", issue = "160728")]
#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
const impl<T> HomogeneousTuple for (T, T, T, T, T, T, T, T, T, T, T, T) {
type Item = T;
}impl_tuples! {
1991 impl_homogeneous_tuple,
1992}
1993
1994#[inline]
2037#[must_use]
2038#[unstable(feature = "cmp_splat", issue = "160728")]
2039#[rustc_const_unstable(feature = "cmp_splat", issue = "160728")]
2040#[expect(private_bounds, reason = "`SmallestArgs` is an internal implementation detail")]
2041#[cfg(not(test))] pub const fn smallest<T: [const] Ord + [const] Destruct>(
2043 #[rustc_splat] args: impl [const] SmallestArgs<Item = T>,
2044) -> T {
2045 SmallestArgs::smallest(args)
2046}
2047
2048#[diagnostic::on_unimplemented(message = "`{Self}` is not a valid set of arguments for `smallest`")]
2050#[unstable(feature = "cmp_splat_internals", issue = "160728")]
2051#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
2052const trait SmallestArgs: HomogeneousTuple {
2053 fn smallest(self) -> Self::Item;
2055}
2056
2057macro impl_smallest_args($($x:ident, $($($y:ident,)+)?)?) {
2059 $(
2060 #[unstable(feature = "cmp_splat_internals", issue = "160728")]
2061 #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
2062 const impl<T> SmallestArgs for (T, $($(${ignore($y)}T,)+)?)
2063 $(where T: [const] Destruct + [const] Ord, $(${ignore($y)})+)?
2064 {
2065 #[inline]
2066 fn smallest(self) -> Self::Item {
2067 let ($x, $($($y,)+)?) = self;
2068 $($(let $x = $x.min($y);)+)?
2069 $x
2070 }
2071 }
2072 )?
2073}
2074
2075#[unstable(feature = "cmp_splat_internals", issue = "160728")]
#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
const impl<T> SmallestArgs for (T, T, T, T, T, T, T, T, T, T, T, T) where
T: [const] Destruct + [const] Ord {
#[inline]
fn smallest(self) -> Self::Item {
let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) = self;
let x0 = x0.min(x1);
let x0 = x0.min(x2);
let x0 = x0.min(x3);
let x0 = x0.min(x4);
let x0 = x0.min(x5);
let x0 = x0.min(x6);
let x0 = x0.min(x7);
let x0 = x0.min(x8);
let x0 = x0.min(x9);
let x0 = x0.min(x10);
let x0 = x0.min(x11);
x0
}
}impl_tuples! {
2076 impl_smallest_args,
2077}
2078
2079#[inline]
2122#[must_use]
2123#[unstable(feature = "cmp_splat", issue = "160728")]
2124#[rustc_const_unstable(feature = "cmp_splat", issue = "160728")]
2125#[expect(private_bounds, reason = "`LargestArgs` is an internal implementation detail")]
2126#[cfg(not(test))] pub const fn largest<T: [const] Ord + [const] Destruct>(
2128 #[rustc_splat] args: impl [const] LargestArgs<Item = T>,
2129) -> T {
2130 LargestArgs::largest(args)
2131}
2132
2133#[diagnostic::on_unimplemented(message = "`{Self}` is not a valid set of arguments for `largest`")]
2135#[unstable(feature = "cmp_splat_internals", issue = "160728")]
2136#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
2137const trait LargestArgs: HomogeneousTuple {
2138 fn largest(self) -> Self::Item;
2140}
2141
2142macro impl_largest_args($($x:ident, $($($y:ident,)+)?)?) {
2144 $(
2145 #[unstable(feature = "cmp_splat_internals", issue = "160728")]
2146 #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
2147 const impl<T> LargestArgs for (T, $($(${ignore($y)}T,)+)?)
2148 $(where T: [const] Destruct + [const] Ord, $(${ignore($y)})+)?
2149 {
2150 #[inline]
2151 fn largest(self) -> Self::Item {
2152 let ($x, $($($y,)+)?) = self;
2153 $($(let $x = $x.max($y);)+)?
2154 $x
2155 }
2156 }
2157 )?
2158}
2159
2160#[unstable(feature = "cmp_splat_internals", issue = "160728")]
#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
const impl<T> LargestArgs for (T, T, T, T, T, T, T, T, T, T, T, T) where
T: [const] Destruct + [const] Ord {
#[inline]
fn largest(self) -> Self::Item {
let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) = self;
let x0 = x0.max(x1);
let x0 = x0.max(x2);
let x0 = x0.max(x3);
let x0 = x0.max(x4);
let x0 = x0.max(x5);
let x0 = x0.max(x6);
let x0 = x0.max(x7);
let x0 = x0.max(x8);
let x0 = x0.max(x9);
let x0 = x0.max(x10);
let x0 = x0.max(x11);
x0
}
}impl_tuples! {
2161 impl_largest_args,
2162}
2163
2164mod impls {
2166 use crate::cmp::Ordering::{self, Equal, Greater, Less};
2167 use crate::hint::unreachable_unchecked;
2168 use crate::marker::PointeeSized;
2169 use crate::ops::ControlFlow::{self, Break, Continue};
2170 use crate::panic::const_assert;
2171
2172 macro_rules! impl_partial_eq_for_primitive {
2180 ($($t:ty)*) => ($(
2181 #[stable(feature = "rust1", since = "1.0.0")]
2182 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2183 const impl PartialEq for $t {
2184 #[inline]
2185 fn eq(&self, other: &Self) -> bool { *self == *other }
2186 #[inline]
2188 fn ne(&self, other: &Self) -> bool { *self != *other }
2189 }
2190 )*)
2191 }
2192
2193 #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for bool {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for char {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for usize {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for u8 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for u16 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for u32 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for u64 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for u128 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for isize {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for i8 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for i16 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for i32 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for i64 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for i128 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for f16 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for f32 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for f64 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialEq for f128 {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
fn ne(&self, other: &Self) -> bool { *self != *other }
}impl_partial_eq_for_primitive! {
2194 bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
2195 }
2196
2197 #[stable(feature = "rust1", since = "1.0.0")]
2198 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2199 const impl PartialEq for () {
2200 #[inline]
2201 fn eq(&self, _other: &()) -> bool {
2202 true
2203 }
2204 #[inline]
2205 fn ne(&self, _other: &()) -> bool {
2206 false
2207 }
2208 }
2209
2210 macro_rules! eq_impl {
2211 ($($t:ty)*) => ($(
2212 #[stable(feature = "rust1", since = "1.0.0")]
2213 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2214 const impl Eq for $t {}
2215 )*)
2216 }
2217
2218 #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for () { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for bool { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for char { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for usize { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for u8 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for u16 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for u32 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for u64 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for u128 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for isize { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for i8 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for i16 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for i32 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for i64 { }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Eq for i128 { }eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
2219
2220 #[rustfmt::skip]
2221 macro_rules! partial_ord_methods_primitive_impl {
2222 () => {
2223 #[inline(always)]
2224 fn lt(&self, other: &Self) -> bool { *self < *other }
2225 #[inline(always)]
2226 fn le(&self, other: &Self) -> bool { *self <= *other }
2227 #[inline(always)]
2228 fn gt(&self, other: &Self) -> bool { *self > *other }
2229 #[inline(always)]
2230 fn ge(&self, other: &Self) -> bool { *self >= *other }
2231
2232 #[inline]
2237 fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
2238 let (lhs, rhs) = (*self, *other);
2239 if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
2240 }
2241 #[inline]
2242 fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
2243 let (lhs, rhs) = (*self, *other);
2244 if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
2245 }
2246 #[inline]
2247 fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
2248 let (lhs, rhs) = (*self, *other);
2249 if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
2250 }
2251 #[inline]
2252 fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
2253 let (lhs, rhs) = (*self, *other);
2254 if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
2255 }
2256 };
2257 }
2258
2259 macro_rules! partial_ord_impl {
2260 ($($t:ty)*) => ($(
2261 #[stable(feature = "rust1", since = "1.0.0")]
2262 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2263 const impl PartialOrd for $t {
2264 #[inline]
2265 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
2266 match (*self <= *other, *self >= *other) {
2267 (false, false) => None,
2268 (false, true) => Some(Greater),
2269 (true, false) => Some(Less),
2270 (true, true) => Some(Equal),
2271 }
2272 }
2273
2274 partial_ord_methods_primitive_impl!();
2275 }
2276 )*)
2277 }
2278
2279 #[stable(feature = "rust1", since = "1.0.0")]
2280 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2281 const impl PartialOrd for () {
2282 #[inline]
2283 fn partial_cmp(&self, _: &()) -> Option<Ordering> {
2284 Some(Equal)
2285 }
2286 }
2287
2288 #[stable(feature = "rust1", since = "1.0.0")]
2289 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2290 const impl PartialOrd for bool {
2291 #[inline]
2292 fn partial_cmp(&self, other: &bool) -> Option<Ordering> {
2293 Some(self.cmp(other))
2294 }
2295
2296 #[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}partial_ord_methods_primitive_impl!();
2297 }
2298
2299 #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for f16 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (*self <= *other, *self >= *other) {
(false, false) => None,
(false, true) => Some(Greater),
(true, false) => Some(Less),
(true, true) => Some(Equal),
}
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for f32 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (*self <= *other, *self >= *other) {
(false, false) => None,
(false, true) => Some(Greater),
(true, false) => Some(Less),
(true, true) => Some(Equal),
}
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for f64 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (*self <= *other, *self >= *other) {
(false, false) => None,
(false, true) => Some(Greater),
(true, false) => Some(Less),
(true, true) => Some(Equal),
}
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for f128 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (*self <= *other, *self >= *other) {
(false, false) => None,
(false, true) => Some(Greater),
(true, false) => Some(Less),
(true, true) => Some(Equal),
}
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}partial_ord_impl! { f16 f32 f64 f128 }
2300
2301 macro_rules! ord_impl {
2302 ($($t:ty)*) => ($(
2303 #[stable(feature = "rust1", since = "1.0.0")]
2304 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2305 const impl PartialOrd for $t {
2306 #[inline]
2307 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
2308 Some(crate::intrinsics::three_way_compare(*self, *other))
2309 }
2310
2311 partial_ord_methods_primitive_impl!();
2312 }
2313
2314 #[stable(feature = "rust1", since = "1.0.0")]
2315 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2316 const impl Ord for $t {
2317 #[inline]
2318 fn cmp(&self, other: &Self) -> Ordering {
2319 crate::intrinsics::three_way_compare(*self, *other)
2320 }
2321
2322 #[inline]
2323 #[track_caller]
2324 fn clamp(self, min: Self, max: Self) -> Self
2325 {
2326 const_assert!(
2327 min <= max,
2328 "min > max",
2329 "min > max. min = {min:?}, max = {max:?}",
2330 min: $t,
2331 max: $t,
2332 );
2333 if self < min {
2334 min
2335 } else if self > max {
2336 max
2337 } else {
2338 self
2339 }
2340 }
2341 }
2342 )*)
2343 }
2344
2345 #[stable(feature = "rust1", since = "1.0.0")]
2346 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2347 const impl Ord for () {
2348 #[inline]
2349 fn cmp(&self, _other: &()) -> Ordering {
2350 Equal
2351 }
2352 }
2353
2354 #[stable(feature = "rust1", since = "1.0.0")]
2355 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2356 const impl Ord for bool {
2357 #[inline]
2358 fn cmp(&self, other: &bool) -> Ordering {
2359 match (*self as i8) - (*other as i8) {
2363 -1 => Less,
2364 0 => Equal,
2365 1 => Greater,
2366 _ => unsafe { unreachable_unchecked() },
2368 }
2369 }
2370
2371 #[inline]
2372 fn min(self, other: bool) -> bool {
2373 self & other
2374 }
2375
2376 #[inline]
2377 fn max(self, other: bool) -> bool {
2378 self | other
2379 }
2380
2381 #[inline]
2382 fn clamp(self, min: bool, max: bool) -> bool {
2383 if !(min <= max) { crate::panicking::panic("assertion failed: min <= max") };assert!(min <= max);
2384 self.max(min).min(max)
2385 }
2386 }
2387
2388 #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for char {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for char {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: char, max: char) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: char, max: char) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: char, max: char) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for usize {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for usize {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: usize, max: usize) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: usize, max: usize) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: usize, max: usize) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for u8 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for u8 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: u8, max: u8) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: u8, max: u8) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: u8, max: u8) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for u16 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for u16 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: u16, max: u16) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: u16, max: u16) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: u16, max: u16) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for u32 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for u32 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: u32, max: u32) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: u32, max: u32) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: u32, max: u32) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for u64 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for u64 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: u64, max: u64) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: u64, max: u64) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: u64, max: u64) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for u128 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for u128 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: u128, max: u128) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: u128, max: u128) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: u128, max: u128) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for isize {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for isize {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: isize, max: isize) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: isize, max: isize) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: isize, max: isize) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for i8 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for i8 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: i8, max: i8) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: i8, max: i8) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: i8, max: i8) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for i16 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for i16 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: i16, max: i16) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: i16, max: i16) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: i16, max: i16) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for i32 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for i32 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: i32, max: i32) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: i32, max: i32) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: i32, max: i32) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for i64 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for i64 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: i64, max: i64) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: i64, max: i64) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: i64, max: i64) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl PartialOrd for i128 {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
}
#[inline(always)]
fn lt(&self, other: &Self) -> bool { *self < *other }
#[inline(always)]
fn le(&self, other: &Self) -> bool { *self <= *other }
#[inline(always)]
fn gt(&self, other: &Self) -> bool { *self > *other }
#[inline(always)]
fn ge(&self, other: &Self) -> bool { *self >= *other }
#[inline]
fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
}
#[inline]
fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
}
#[inline]
fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
}
#[inline]
fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
let (lhs, rhs) = (*self, *other);
if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
const impl Ord for i128 {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
}
#[inline]
#[track_caller]
fn clamp(self, min: Self, max: Self) -> Self {
{
if !(min <= max) {
{
#[rustc_allow_const_fn_unstable(const_eval_select)]
#[inline(always)]
#[track_caller]
const fn do_panic(min: i128, max: i128) -> ! {
{
#[inline]
#[track_caller]
fn runtime(min: i128, max: i128) -> ! {
{
{
crate::panicking::panic_fmt(format_args!("min > max. min = {0:?}, max = {1:?}",
min, max));
}
}
}
#[inline]
#[track_caller]
const fn compiletime(min: i128, max: i128) -> ! {
let _ = min;
let _ = max;
{
{ crate::panicking::panic_fmt(format_args!("min > max")); }
}
}
const_eval_select((min, max), compiletime, runtime)
}
}
do_panic(min, max)
}
}
};
if self < min { min } else if self > max { max } else { self }
}
}ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
2389
2390 #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")]
2391 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2392 const impl PartialEq for ! {
2393 #[inline]
2394 fn eq(&self, _: &!) -> bool {
2395 *self
2396 }
2397 }
2398
2399 #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")]
2400 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2401 const impl Eq for ! {}
2402
2403 #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")]
2404 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2405 const impl PartialOrd for ! {
2406 #[inline]
2407 fn partial_cmp(&self, _: &!) -> Option<Ordering> {
2408 *self
2409 }
2410 }
2411
2412 #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")]
2413 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2414 const impl Ord for ! {
2415 #[inline]
2416 fn cmp(&self, _: &!) -> Ordering {
2417 *self
2418 }
2419 }
2420
2421 #[stable(feature = "rust1", since = "1.0.0")]
2424 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2425 const impl<A: PointeeSized, B: PointeeSized> PartialEq<&B> for &A
2426 where
2427 A: [const] PartialEq<B>,
2428 {
2429 #[inline]
2430 fn eq(&self, other: &&B) -> bool {
2431 PartialEq::eq(*self, *other)
2432 }
2433 #[inline]
2434 fn ne(&self, other: &&B) -> bool {
2435 PartialEq::ne(*self, *other)
2436 }
2437 }
2438 #[stable(feature = "rust1", since = "1.0.0")]
2439 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2440 const impl<A: PointeeSized, B: PointeeSized> PartialOrd<&B> for &A
2441 where
2442 A: [const] PartialOrd<B>,
2443 {
2444 #[inline]
2445 fn partial_cmp(&self, other: &&B) -> Option<Ordering> {
2446 PartialOrd::partial_cmp(*self, *other)
2447 }
2448 #[inline]
2449 fn lt(&self, other: &&B) -> bool {
2450 PartialOrd::lt(*self, *other)
2451 }
2452 #[inline]
2453 fn le(&self, other: &&B) -> bool {
2454 PartialOrd::le(*self, *other)
2455 }
2456 #[inline]
2457 fn gt(&self, other: &&B) -> bool {
2458 PartialOrd::gt(*self, *other)
2459 }
2460 #[inline]
2461 fn ge(&self, other: &&B) -> bool {
2462 PartialOrd::ge(*self, *other)
2463 }
2464 #[inline]
2465 fn __chaining_lt(&self, other: &&B) -> ControlFlow<bool> {
2466 PartialOrd::__chaining_lt(*self, *other)
2467 }
2468 #[inline]
2469 fn __chaining_le(&self, other: &&B) -> ControlFlow<bool> {
2470 PartialOrd::__chaining_le(*self, *other)
2471 }
2472 #[inline]
2473 fn __chaining_gt(&self, other: &&B) -> ControlFlow<bool> {
2474 PartialOrd::__chaining_gt(*self, *other)
2475 }
2476 #[inline]
2477 fn __chaining_ge(&self, other: &&B) -> ControlFlow<bool> {
2478 PartialOrd::__chaining_ge(*self, *other)
2479 }
2480 }
2481 #[stable(feature = "rust1", since = "1.0.0")]
2482 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2483 const impl<A: PointeeSized> Ord for &A
2484 where
2485 A: [const] Ord,
2486 {
2487 #[inline]
2488 fn cmp(&self, other: &Self) -> Ordering {
2489 Ord::cmp(*self, *other)
2490 }
2491 }
2492 #[stable(feature = "rust1", since = "1.0.0")]
2493 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2494 const impl<A: PointeeSized> Eq for &A where A: [const] Eq {}
2495
2496 #[stable(feature = "rust1", since = "1.0.0")]
2499 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2500 const impl<A: PointeeSized, B: PointeeSized> PartialEq<&mut B> for &mut A
2501 where
2502 A: [const] PartialEq<B>,
2503 {
2504 #[inline]
2505 fn eq(&self, other: &&mut B) -> bool {
2506 PartialEq::eq(*self, *other)
2507 }
2508 #[inline]
2509 fn ne(&self, other: &&mut B) -> bool {
2510 PartialEq::ne(*self, *other)
2511 }
2512 }
2513 #[stable(feature = "rust1", since = "1.0.0")]
2514 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2515 const impl<A: PointeeSized, B: PointeeSized> PartialOrd<&mut B> for &mut A
2516 where
2517 A: [const] PartialOrd<B>,
2518 {
2519 #[inline]
2520 fn partial_cmp(&self, other: &&mut B) -> Option<Ordering> {
2521 PartialOrd::partial_cmp(*self, *other)
2522 }
2523 #[inline]
2524 fn lt(&self, other: &&mut B) -> bool {
2525 PartialOrd::lt(*self, *other)
2526 }
2527 #[inline]
2528 fn le(&self, other: &&mut B) -> bool {
2529 PartialOrd::le(*self, *other)
2530 }
2531 #[inline]
2532 fn gt(&self, other: &&mut B) -> bool {
2533 PartialOrd::gt(*self, *other)
2534 }
2535 #[inline]
2536 fn ge(&self, other: &&mut B) -> bool {
2537 PartialOrd::ge(*self, *other)
2538 }
2539 #[inline]
2540 fn __chaining_lt(&self, other: &&mut B) -> ControlFlow<bool> {
2541 PartialOrd::__chaining_lt(*self, *other)
2542 }
2543 #[inline]
2544 fn __chaining_le(&self, other: &&mut B) -> ControlFlow<bool> {
2545 PartialOrd::__chaining_le(*self, *other)
2546 }
2547 #[inline]
2548 fn __chaining_gt(&self, other: &&mut B) -> ControlFlow<bool> {
2549 PartialOrd::__chaining_gt(*self, *other)
2550 }
2551 #[inline]
2552 fn __chaining_ge(&self, other: &&mut B) -> ControlFlow<bool> {
2553 PartialOrd::__chaining_ge(*self, *other)
2554 }
2555 }
2556 #[stable(feature = "rust1", since = "1.0.0")]
2557 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2558 const impl<A: PointeeSized> Ord for &mut A
2559 where
2560 A: [const] Ord,
2561 {
2562 #[inline]
2563 fn cmp(&self, other: &Self) -> Ordering {
2564 Ord::cmp(*self, *other)
2565 }
2566 }
2567 #[stable(feature = "rust1", since = "1.0.0")]
2568 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2569 const impl<A: PointeeSized> Eq for &mut A where A: [const] Eq {}
2570
2571 #[stable(feature = "rust1", since = "1.0.0")]
2572 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2573 const impl<A: PointeeSized, B: PointeeSized> PartialEq<&mut B> for &A
2574 where
2575 A: [const] PartialEq<B>,
2576 {
2577 #[inline]
2578 fn eq(&self, other: &&mut B) -> bool {
2579 PartialEq::eq(*self, *other)
2580 }
2581 #[inline]
2582 fn ne(&self, other: &&mut B) -> bool {
2583 PartialEq::ne(*self, *other)
2584 }
2585 }
2586
2587 #[stable(feature = "rust1", since = "1.0.0")]
2588 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2589 const impl<A: PointeeSized, B: PointeeSized> PartialEq<&B> for &mut A
2590 where
2591 A: [const] PartialEq<B>,
2592 {
2593 #[inline]
2594 fn eq(&self, other: &&B) -> bool {
2595 PartialEq::eq(*self, *other)
2596 }
2597 #[inline]
2598 fn ne(&self, other: &&B) -> bool {
2599 PartialEq::ne(*self, *other)
2600 }
2601 }
2602}