#[cfg(feature = "itertools")]
mod all_equal;
mod max;
mod max_by;
mod max_by_key;
mod min;
mod min_by;
mod min_by_key;
#[cfg(feature = "itertools")]
mod min_max;
mod value_key;
#[cfg(feature = "itertools")]
pub use all_equal::*;
pub use max::*;
pub use max_by::*;
pub use max_by_key::*;
pub use min::*;
pub use min_by::*;
pub use min_by_key::*;
#[cfg(feature = "itertools")]
pub use min_max::*;
#[inline]
fn max_assign<T: Ord>(max: &mut T, value: T) {
if value < *max {
} else {
*max = value
}
}
#[inline]
fn min_assign<T: Ord>(min: &mut T, value: T) {
if value < *min {
*min = value
}
}
#[cfg(test)]
#[allow(dead_code)]
mod test_utils {
use std::cmp::Ordering;
#[cfg(feature = "itertools")]
use itertools::MinMaxResult;
#[derive(Debug, Clone, Copy, Eq)]
pub struct Id {
pub id: usize,
pub num: i32,
}
impl Id {
pub fn full_eq(self, other: Self) -> bool {
self.id == other.id && self.num == other.num
}
pub fn full_eq_opt(x: Option<Self>, y: Option<Self>) -> bool {
match (x, y) {
(Some(x), Some(y)) => x.full_eq(y),
(None, None) => true,
_ => false,
}
}
#[cfg(feature = "itertools")]
pub fn full_eq_minmax_res(x: MinMaxResult<Self>, y: MinMaxResult<Self>) -> bool {
x.into_option() == y.into_option()
}
}
impl PartialEq for Id {
fn eq(&self, other: &Self) -> bool {
self.num == other.num
}
}
impl PartialOrd for Id {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Id {
fn cmp(&self, other: &Self) -> Ordering {
self.num.cmp(&other.num)
}
}
}