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) {
crate::hash::Hash::hash(&crate::intrinsics::discriminant_value(self),
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) -> Self { *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 { }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: &Self)
-> 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: &Self) -> crate::cmp::Ordering {
crate::cmp::Ord::cmp(&crate::intrinsics::discriminant_value(self),
&crate::intrinsics::discriminant_value(other))
}
}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: &Self) -> bool {
crate::intrinsics::discriminant_value(self) ==
crate::intrinsics::discriminant_value(other)
}
}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: &Self) -> 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() -> Self { 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) -> Self {
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")]
1974#[unstable(feature = "cmp_splat_internals", issue = "160728")]
1975#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
1976const trait HomogeneousTuple<T>: crate::marker::Tuple {}
1977
1978macro impl_homogeneous_tuple($($x:ident,)*) {
1980 #[unstable(feature = "cmp_splat_internals", issue = "160728")]
1981 #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
1982 const impl<T> HomogeneousTuple<T> for ($(${ignore($x)}T,)*) { }
1983}
1984
1985#[unstable(feature = "cmp_splat_internals", issue = "160728")]
#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
const impl<T> HomogeneousTuple<T> for (T, T, T, T, T, T, T, T, T, T, T, T) { }impl_tuples! {
1986 impl_homogeneous_tuple,
1987}
1988
1989#[inline]
2032#[must_use]
2033#[unstable(feature = "cmp_splat", issue = "160728")]
2034#[rustc_const_unstable(feature = "cmp_splat", issue = "160728")]
2035#[expect(private_bounds, reason = "`SmallestArgs` is an internal implementation detail")]
2036#[cfg(not(test))] pub const fn smallest<T: [const] Ord + [const] Destruct>(
2038 v1: T,
2039 #[rustc_splat] args: impl [const] SmallestArgs<T>,
2040) -> T {
2041 SmallestArgs::smallest(v1, args)
2042}
2043
2044#[diagnostic::on_unimplemented(message = "`{Self}` is not a valid set of arguments for `smallest`")]
2046#[unstable(feature = "cmp_splat_internals", issue = "160728")]
2047#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
2048const trait SmallestArgs<T>: HomogeneousTuple<T> {
2049 fn smallest(v1: T, args: Self) -> T;
2051}
2052
2053macro impl_smallest_args($($x:ident,)*) {
2055 #[unstable(feature = "cmp_splat_internals", issue = "160728")]
2056 #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
2057 const impl<T> SmallestArgs<T> for ($(${ignore($x)}T,)*)
2058 where
2059 T: [const] Destruct + [const] Ord,
2060 {
2061 #[inline(always)] fn smallest(v1: T, ($($x,)*): Self) -> T {
2063 v1$(.min($x))*
2064 }
2065 }
2066}
2067
2068#[unstable(feature = "cmp_splat_internals", issue = "160728")]
#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
const impl<T> SmallestArgs<T> for (T, T, T, T, T, T, T, T, T, T, T, T) where
T: [const] Destruct + [const] Ord {
#[inline(always)]
fn smallest(v1: T,
(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11): Self) -> T {
v1.min(x0).min(x1).min(x2).min(x3).min(x4).min(x5).min(x6).min(x7).min(x8).min(x9).min(x10).min(x11)
}
}impl_tuples! {
2069 impl_smallest_args,
2070}
2071
2072#[inline]
2115#[must_use]
2116#[unstable(feature = "cmp_splat", issue = "160728")]
2117#[rustc_const_unstable(feature = "cmp_splat", issue = "160728")]
2118#[expect(private_bounds, reason = "`LargestArgs` is an internal implementation detail")]
2119#[cfg(not(test))] pub const fn largest<T: [const] Ord + [const] Destruct>(
2121 v1: T,
2122 #[rustc_splat] args: impl [const] LargestArgs<T>,
2123) -> T {
2124 LargestArgs::largest(v1, args)
2125}
2126
2127#[diagnostic::on_unimplemented(message = "`{Self}` is not a valid set of arguments for `largest`")]
2129#[unstable(feature = "cmp_splat_internals", issue = "160728")]
2130#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
2131const trait LargestArgs<T>: HomogeneousTuple<T> {
2132 fn largest(v1: T, args: Self) -> T;
2134}
2135
2136macro impl_largest_args($($x:ident,)*) {
2138 #[unstable(feature = "cmp_splat_internals", issue = "160728")]
2139 #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
2140 const impl<T> LargestArgs<T> for ($(${ignore($x)}T,)*)
2141 where
2142 T: [const] Destruct + [const] Ord,
2143 {
2144 #[inline(always)] fn largest(v1: T, ($($x,)*): Self) -> T {
2146 v1$(.max($x))*
2147 }
2148 }
2149}
2150
2151#[unstable(feature = "cmp_splat_internals", issue = "160728")]
#[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")]
const impl<T> LargestArgs<T> for (T, T, T, T, T, T, T, T, T, T, T, T) where
T: [const] Destruct + [const] Ord {
#[inline(always)]
fn largest(v1: T,
(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11): Self) -> T {
v1.max(x0).max(x1).max(x2).max(x3).max(x4).max(x5).max(x6).max(x7).max(x8).max(x9).max(x10).max(x11)
}
}impl_tuples! {
2152 impl_largest_args,
2153}
2154
2155mod impls {
2157 use crate::cmp::Ordering::{self, Equal, Greater, Less};
2158 use crate::hint::unreachable_unchecked;
2159 use crate::marker::PointeeSized;
2160 use crate::ops::ControlFlow::{self, Break, Continue};
2161 use crate::panic::const_assert;
2162
2163 macro_rules! impl_partial_eq_for_primitive {
2171 ($($t:ty)*) => ($(
2172 #[stable(feature = "rust1", since = "1.0.0")]
2173 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2174 const impl PartialEq for $t {
2175 #[inline]
2176 fn eq(&self, other: &Self) -> bool { *self == *other }
2177 #[inline]
2179 fn ne(&self, other: &Self) -> bool { *self != *other }
2180 }
2181 )*)
2182 }
2183
2184 #[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! {
2185 bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
2186 }
2187
2188 #[stable(feature = "rust1", since = "1.0.0")]
2189 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2190 const impl PartialEq for () {
2191 #[inline]
2192 fn eq(&self, _other: &()) -> bool {
2193 true
2194 }
2195 #[inline]
2196 fn ne(&self, _other: &()) -> bool {
2197 false
2198 }
2199 }
2200
2201 macro_rules! eq_impl {
2202 ($($t:ty)*) => ($(
2203 #[stable(feature = "rust1", since = "1.0.0")]
2204 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2205 const impl Eq for $t {}
2206 )*)
2207 }
2208
2209 #[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 }
2210
2211 #[rustfmt::skip]
2212 macro_rules! partial_ord_methods_primitive_impl {
2213 () => {
2214 #[inline(always)]
2215 fn lt(&self, other: &Self) -> bool { *self < *other }
2216 #[inline(always)]
2217 fn le(&self, other: &Self) -> bool { *self <= *other }
2218 #[inline(always)]
2219 fn gt(&self, other: &Self) -> bool { *self > *other }
2220 #[inline(always)]
2221 fn ge(&self, other: &Self) -> bool { *self >= *other }
2222
2223 #[inline]
2228 fn __chaining_lt(&self, other: &Self) -> ControlFlow<bool> {
2229 let (lhs, rhs) = (*self, *other);
2230 if lhs == rhs { Continue(()) } else { Break(lhs < rhs) }
2231 }
2232 #[inline]
2233 fn __chaining_le(&self, other: &Self) -> ControlFlow<bool> {
2234 let (lhs, rhs) = (*self, *other);
2235 if lhs == rhs { Continue(()) } else { Break(lhs <= rhs) }
2236 }
2237 #[inline]
2238 fn __chaining_gt(&self, other: &Self) -> ControlFlow<bool> {
2239 let (lhs, rhs) = (*self, *other);
2240 if lhs == rhs { Continue(()) } else { Break(lhs > rhs) }
2241 }
2242 #[inline]
2243 fn __chaining_ge(&self, other: &Self) -> ControlFlow<bool> {
2244 let (lhs, rhs) = (*self, *other);
2245 if lhs == rhs { Continue(()) } else { Break(lhs >= rhs) }
2246 }
2247 };
2248 }
2249
2250 macro_rules! partial_ord_impl {
2251 ($($t:ty)*) => ($(
2252 #[stable(feature = "rust1", since = "1.0.0")]
2253 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2254 const impl PartialOrd for $t {
2255 #[inline]
2256 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
2257 match (*self <= *other, *self >= *other) {
2258 (false, false) => None,
2259 (false, true) => Some(Greater),
2260 (true, false) => Some(Less),
2261 (true, true) => Some(Equal),
2262 }
2263 }
2264
2265 partial_ord_methods_primitive_impl!();
2266 }
2267 )*)
2268 }
2269
2270 #[stable(feature = "rust1", since = "1.0.0")]
2271 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2272 const impl PartialOrd for () {
2273 #[inline]
2274 fn partial_cmp(&self, _: &()) -> Option<Ordering> {
2275 Some(Equal)
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 bool {
2282 #[inline]
2283 fn partial_cmp(&self, other: &bool) -> Option<Ordering> {
2284 Some(self.cmp(other))
2285 }
2286
2287 #[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!();
2288 }
2289
2290 #[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 }
2291
2292 macro_rules! min_max_impl {
2293 (char) => {
2294 #[inline]
2295 fn min(self, other: Self) -> Self {
2296 let c = u32::min(self as u32, other as u32);
2297 unsafe { char::from_u32_unchecked(c) }
2299 }
2300
2301 #[inline]
2302 fn max(self, other: Self) -> Self {
2303 let c = u32::max(self as u32, other as u32);
2304 unsafe { char::from_u32_unchecked(c) }
2306 }
2307 };
2308 ($t:ident) => {
2309 #[inline]
2310 fn min(self, other: Self) -> Self {
2311 crate::intrinsics::integer_min(self, other)
2312 }
2313
2314 #[inline]
2315 fn max(self, other: Self) -> Self {
2316 crate::intrinsics::integer_max(self, other)
2317 }
2318 };
2319 }
2320
2321 macro_rules! ord_impl {
2322 ($($t:ident)*) => ($(
2323 #[stable(feature = "rust1", since = "1.0.0")]
2324 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2325 const impl PartialOrd for $t {
2326 #[inline]
2327 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
2328 Some(crate::intrinsics::three_way_compare(*self, *other))
2329 }
2330
2331 partial_ord_methods_primitive_impl!();
2332 }
2333
2334 #[stable(feature = "rust1", since = "1.0.0")]
2335 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2336 const impl Ord for $t {
2337 #[inline]
2338 fn cmp(&self, other: &Self) -> Ordering {
2339 crate::intrinsics::three_way_compare(*self, *other)
2340 }
2341
2342 #[inline]
2343 #[track_caller]
2344 fn clamp(self, min: Self, max: Self) -> Self
2345 {
2346 const_assert!(
2347 min <= max,
2348 "min > max",
2349 "min > max. min = {min:?}, max = {max:?}",
2350 min: $t,
2351 max: $t,
2352 );
2353 if self < min {
2354 min
2355 } else if self > max {
2356 max
2357 } else {
2358 self
2359 }
2360 }
2361
2362 min_max_impl!($t);
2363 }
2364 )*)
2365 }
2366
2367 #[stable(feature = "rust1", since = "1.0.0")]
2368 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2369 const impl Ord for () {
2370 #[inline]
2371 fn cmp(&self, _other: &()) -> Ordering {
2372 Equal
2373 }
2374 }
2375
2376 #[stable(feature = "rust1", since = "1.0.0")]
2377 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2378 const impl Ord for bool {
2379 #[inline]
2380 fn cmp(&self, other: &bool) -> Ordering {
2381 match (*self as i8) - (*other as i8) {
2385 -1 => Less,
2386 0 => Equal,
2387 1 => Greater,
2388 _ => unsafe { unreachable_unchecked() },
2390 }
2391 }
2392
2393 #[inline]
2394 fn min(self, other: bool) -> bool {
2395 self & other
2396 }
2397
2398 #[inline]
2399 fn max(self, other: bool) -> bool {
2400 self | other
2401 }
2402
2403 #[inline]
2404 fn clamp(self, min: bool, max: bool) -> bool {
2405 if !(min <= max) { crate::panicking::panic("assertion failed: min <= max") };assert!(min <= max);
2406 self.max(min).min(max)
2407 }
2408 }
2409
2410 #[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
let c = u32::min(self as u32, other as u32);
unsafe { char::from_u32_unchecked(c) }
}
#[inline]
fn max(self, other: Self) -> Self {
let c = u32::max(self as u32, other as u32);
unsafe { char::from_u32_unchecked(c) }
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}
#[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 }
}
#[inline]
fn min(self, other: Self) -> Self {
crate::intrinsics::integer_min(self, other)
}
#[inline]
fn max(self, other: Self) -> Self {
crate::intrinsics::integer_max(self, other)
}
}ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
2411
2412 #[stable(feature = "never_type", since = "1.100.0")]
2413 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2414 const impl PartialEq for ! {
2415 #[inline]
2416 fn eq(&self, _: &!) -> bool {
2417 *self
2418 }
2419 }
2420
2421 #[stable(feature = "never_type", since = "1.100.0")]
2422 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2423 const impl Eq for ! {}
2424
2425 #[stable(feature = "never_type", since = "1.100.0")]
2426 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2427 const impl PartialOrd for ! {
2428 #[inline]
2429 fn partial_cmp(&self, _: &!) -> Option<Ordering> {
2430 *self
2431 }
2432 }
2433
2434 #[stable(feature = "never_type", since = "1.100.0")]
2435 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2436 const impl Ord for ! {
2437 #[inline]
2438 fn cmp(&self, _: &!) -> Ordering {
2439 *self
2440 }
2441 }
2442
2443 #[stable(feature = "rust1", since = "1.0.0")]
2446 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2447 const impl<A: PointeeSized, B: PointeeSized> PartialEq<&B> for &A
2448 where
2449 A: [const] PartialEq<B>,
2450 {
2451 #[inline]
2452 fn eq(&self, other: &&B) -> bool {
2453 PartialEq::eq(*self, *other)
2454 }
2455 #[inline]
2456 fn ne(&self, other: &&B) -> bool {
2457 PartialEq::ne(*self, *other)
2458 }
2459 }
2460 #[stable(feature = "rust1", since = "1.0.0")]
2461 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2462 const impl<A: PointeeSized, B: PointeeSized> PartialOrd<&B> for &A
2463 where
2464 A: [const] PartialOrd<B>,
2465 {
2466 #[inline]
2467 fn partial_cmp(&self, other: &&B) -> Option<Ordering> {
2468 PartialOrd::partial_cmp(*self, *other)
2469 }
2470 #[inline]
2471 fn lt(&self, other: &&B) -> bool {
2472 PartialOrd::lt(*self, *other)
2473 }
2474 #[inline]
2475 fn le(&self, other: &&B) -> bool {
2476 PartialOrd::le(*self, *other)
2477 }
2478 #[inline]
2479 fn gt(&self, other: &&B) -> bool {
2480 PartialOrd::gt(*self, *other)
2481 }
2482 #[inline]
2483 fn ge(&self, other: &&B) -> bool {
2484 PartialOrd::ge(*self, *other)
2485 }
2486 #[inline]
2487 fn __chaining_lt(&self, other: &&B) -> ControlFlow<bool> {
2488 PartialOrd::__chaining_lt(*self, *other)
2489 }
2490 #[inline]
2491 fn __chaining_le(&self, other: &&B) -> ControlFlow<bool> {
2492 PartialOrd::__chaining_le(*self, *other)
2493 }
2494 #[inline]
2495 fn __chaining_gt(&self, other: &&B) -> ControlFlow<bool> {
2496 PartialOrd::__chaining_gt(*self, *other)
2497 }
2498 #[inline]
2499 fn __chaining_ge(&self, other: &&B) -> ControlFlow<bool> {
2500 PartialOrd::__chaining_ge(*self, *other)
2501 }
2502 }
2503 #[stable(feature = "rust1", since = "1.0.0")]
2504 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2505 const impl<A: PointeeSized> Ord for &A
2506 where
2507 A: [const] Ord,
2508 {
2509 #[inline]
2510 fn cmp(&self, other: &Self) -> Ordering {
2511 Ord::cmp(*self, *other)
2512 }
2513 }
2514 #[stable(feature = "rust1", since = "1.0.0")]
2515 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2516 const impl<A: PointeeSized> Eq for &A where A: [const] Eq {}
2517
2518 #[stable(feature = "rust1", since = "1.0.0")]
2521 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2522 const impl<A: PointeeSized, B: PointeeSized> PartialEq<&mut B> for &mut A
2523 where
2524 A: [const] PartialEq<B>,
2525 {
2526 #[inline]
2527 fn eq(&self, other: &&mut B) -> bool {
2528 PartialEq::eq(*self, *other)
2529 }
2530 #[inline]
2531 fn ne(&self, other: &&mut B) -> bool {
2532 PartialEq::ne(*self, *other)
2533 }
2534 }
2535 #[stable(feature = "rust1", since = "1.0.0")]
2536 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2537 const impl<A: PointeeSized, B: PointeeSized> PartialOrd<&mut B> for &mut A
2538 where
2539 A: [const] PartialOrd<B>,
2540 {
2541 #[inline]
2542 fn partial_cmp(&self, other: &&mut B) -> Option<Ordering> {
2543 PartialOrd::partial_cmp(*self, *other)
2544 }
2545 #[inline]
2546 fn lt(&self, other: &&mut B) -> bool {
2547 PartialOrd::lt(*self, *other)
2548 }
2549 #[inline]
2550 fn le(&self, other: &&mut B) -> bool {
2551 PartialOrd::le(*self, *other)
2552 }
2553 #[inline]
2554 fn gt(&self, other: &&mut B) -> bool {
2555 PartialOrd::gt(*self, *other)
2556 }
2557 #[inline]
2558 fn ge(&self, other: &&mut B) -> bool {
2559 PartialOrd::ge(*self, *other)
2560 }
2561 #[inline]
2562 fn __chaining_lt(&self, other: &&mut B) -> ControlFlow<bool> {
2563 PartialOrd::__chaining_lt(*self, *other)
2564 }
2565 #[inline]
2566 fn __chaining_le(&self, other: &&mut B) -> ControlFlow<bool> {
2567 PartialOrd::__chaining_le(*self, *other)
2568 }
2569 #[inline]
2570 fn __chaining_gt(&self, other: &&mut B) -> ControlFlow<bool> {
2571 PartialOrd::__chaining_gt(*self, *other)
2572 }
2573 #[inline]
2574 fn __chaining_ge(&self, other: &&mut B) -> ControlFlow<bool> {
2575 PartialOrd::__chaining_ge(*self, *other)
2576 }
2577 }
2578 #[stable(feature = "rust1", since = "1.0.0")]
2579 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2580 const impl<A: PointeeSized> Ord for &mut A
2581 where
2582 A: [const] Ord,
2583 {
2584 #[inline]
2585 fn cmp(&self, other: &Self) -> Ordering {
2586 Ord::cmp(*self, *other)
2587 }
2588 }
2589 #[stable(feature = "rust1", since = "1.0.0")]
2590 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2591 const impl<A: PointeeSized> Eq for &mut A where A: [const] Eq {}
2592
2593 #[stable(feature = "rust1", since = "1.0.0")]
2594 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2595 const impl<A: PointeeSized, B: PointeeSized> PartialEq<&mut B> for &A
2596 where
2597 A: [const] PartialEq<B>,
2598 {
2599 #[inline]
2600 fn eq(&self, other: &&mut B) -> bool {
2601 PartialEq::eq(*self, *other)
2602 }
2603 #[inline]
2604 fn ne(&self, other: &&mut B) -> bool {
2605 PartialEq::ne(*self, *other)
2606 }
2607 }
2608
2609 #[stable(feature = "rust1", since = "1.0.0")]
2610 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
2611 const impl<A: PointeeSized, B: PointeeSized> PartialEq<&B> for &mut A
2612 where
2613 A: [const] PartialEq<B>,
2614 {
2615 #[inline]
2616 fn eq(&self, other: &&B) -> bool {
2617 PartialEq::eq(*self, *other)
2618 }
2619 #[inline]
2620 fn ne(&self, other: &&B) -> bool {
2621 PartialEq::ne(*self, *other)
2622 }
2623 }
2624}