1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::cmp::Ordering;
use std::convert::Infallible;

pub trait TryPartialOrd<Rhs, E> {
    fn try_partial_cmp(&self, rhs: &Rhs) -> Result<Option<Ordering>, E>;
}

impl<Lhs, Rhs> TryPartialOrd<Rhs, Infallible> for Lhs
where
    Lhs: PartialOrd<Rhs>,
{
    fn try_partial_cmp(&self, rhs: &Rhs) -> Result<Option<Ordering>, Infallible> {
        Ok(self.partial_cmp(rhs))
    }
}