use std::fmt::Debug;
#[derive(Debug, Clone, PartialEq)]
pub enum LowEndpoint<T>
where
T: Debug + PartialEq,
{
Start,
RangeInclusive(T),
RangeExclusive(T),
}
impl<T> LowEndpoint<T>
where
T: Debug + PartialEq,
{
pub(crate) fn map<F, U>(self, f: F) -> LowEndpoint<U>
where
F: FnOnce(T) -> U,
U: Debug + PartialEq,
{
match self {
LowEndpoint::Start => LowEndpoint::Start,
LowEndpoint::RangeInclusive(t) => LowEndpoint::RangeInclusive(f(t)),
LowEndpoint::RangeExclusive(t) => LowEndpoint::RangeExclusive(f(t)),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum HighEndpoint<T>
where
T: Debug + PartialEq,
{
RangeInclusive(T),
RangeExclusive(T),
End,
}
impl<T> HighEndpoint<T>
where
T: Debug + PartialEq,
{
pub(crate) fn map<F, U>(self, f: F) -> HighEndpoint<U>
where
F: FnOnce(T) -> U,
U: Debug + PartialEq,
{
match self {
HighEndpoint::RangeInclusive(t) => HighEndpoint::RangeInclusive(f(t)),
HighEndpoint::RangeExclusive(t) => HighEndpoint::RangeExclusive(f(t)),
HighEndpoint::End => HighEndpoint::End,
}
}
}
#[cfg(test)]
mod tests {
}