bs-trace 0.3.0

Free RayTracing software
Documentation
use std::cmp::Ordering;

pub fn option_ordering_max_none<T>(x: &Option<T>, y: &Option<T>) -> Ordering
where
    T: Ord,
{
    match x {
        Some(x) => match y {
            Some(y) => x.cmp(y),
            None => Ordering::Less,
        },
        None => match y {
            Some(_) => Ordering::Greater,
            None => Ordering::Equal,
        },
    }
}

pub fn option_ordering_min_none<T>(x: &Option<T>, y: &Option<T>) -> Ordering
where
    T: Ord,
{
    match x {
        Some(x) => match y {
            Some(y) => x.cmp(y),
            None => Ordering::Greater,
        },
        None => match y {
            Some(_) => Ordering::Less,
            None => Ordering::Equal,
        },
    }
}