Skip to content

Commit b132b9f

Browse files
committed
Implement SpecOptionPartialEq for cmp::Ordering
1 parent 17e44cb commit b132b9f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

core/src/option.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ use crate::marker::Destruct;
551551
use crate::panicking::{panic, panic_str};
552552
use crate::pin::Pin;
553553
use crate::{
554-
convert, hint, mem,
554+
cmp, convert, hint, mem,
555555
ops::{self, ControlFlow, Deref, DerefMut},
556556
};
557557

@@ -2146,6 +2146,14 @@ impl<T> SpecOptionPartialEq for crate::ptr::NonNull<T> {
21462146
}
21472147
}
21482148

2149+
#[stable(feature = "rust1", since = "1.0.0")]
2150+
impl SpecOptionPartialEq for cmp::Ordering {
2151+
#[inline]
2152+
fn eq(l: &Option<Self>, r: &Option<Self>) -> bool {
2153+
l.map_or(2, |x| x as i8) == r.map_or(2, |x| x as i8)
2154+
}
2155+
}
2156+
21492157
/////////////////////////////////////////////////////////////////////////////
21502158
// The Option Iterators
21512159
/////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)