1
Fork 0

Implement SpecOptionPartialEq for cmp::Ordering

This commit is contained in:
Scott McMurray 2023-01-17 22:44:16 -08:00
parent e08b379d5d
commit 3122db7d03
2 changed files with 19 additions and 1 deletions

View file

@ -551,7 +551,7 @@ use crate::marker::Destruct;
use crate::panicking::{panic, panic_str};
use crate::pin::Pin;
use crate::{
convert, hint, mem,
cmp, convert, hint, mem,
ops::{self, ControlFlow, Deref, DerefMut},
};
@ -2146,6 +2146,14 @@ impl<T> SpecOptionPartialEq for crate::ptr::NonNull<T> {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl SpecOptionPartialEq for cmp::Ordering {
#[inline]
fn eq(l: &Option<Self>, r: &Option<Self>) -> bool {
l.map_or(2, |x| x as i8) == r.map_or(2, |x| x as i8)
}
}
/////////////////////////////////////////////////////////////////////////////
// The Option Iterators
/////////////////////////////////////////////////////////////////////////////