We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 65c53c3 commit d409475Copy full SHA for d409475
library/core/src/cmp.rs
@@ -1476,11 +1476,11 @@ mod impls {
1476
impl const Ord for $t {
1477
#[inline]
1478
fn cmp(&self, other: &$t) -> Ordering {
1479
- // The order here is important to generate more optimal assembly.
1480
- // See <https://github.com/rust-lang/rust/issues/63758> for more info.
1481
- if *self < *other { Less }
1482
- else if *self == *other { Equal }
1483
- else { Greater }
+ let mut res = 0i8;
+ res -= (*self < *other) as i8;
+ res += (*self > *other) as i8;
+ // SAFETY: The discriminants of Ord were chosen to permit this
+ unsafe { crate::mem::transmute(res) }
1484
}
1485
1486
)*)
0 commit comments