// ------------------------------------------------------------------------------------------------
// Copyright © 2021, stack-graphs authors.
// Licensed under either of Apache License, Version 2.0, or MIT license, at your option.
// Please see the LICENSE-APACHE or LICENSE-MIT files in this distribution for license details.
// ------------------------------------------------------------------------------------------------
pub(crate) fn equals_option(a: Option, b: Option, mut eq: F) -> bool
where
F: FnMut(A, B) -> bool,
{
match a {
Some(a) => match b {
Some(b) => eq(a, b),
None => false,
},
None => b.is_none(),
}
}
pub(crate) fn cmp_option(a: Option, b: Option, mut cmp: F) -> std::cmp::Ordering
where
F: FnMut(T, T) -> std::cmp::Ordering,
{
use std::cmp::Ordering;
match a {
Some(a) => match b {
Some(b) => cmp(a, b),
None => Ordering::Greater,
},
None => match b {
Some(_) => Ordering::Less,
None => Ordering::Equal,
},
}
}