use crate::conv::*;
use crate::parts::*;
use crate::*;
use core::borrow::Borrow;
use core::cmp::Ordering;
use core::marker::PhantomData;
use core::mem;
use core::ops::{Add, Sub};
use core::ops::{BitAnd, BitOr, BitXor, Shl, Shr};
use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign};
use core::ops::{Bound, Range, RangeBounds};
#[repr(transparent)]
#[derive(Debug, Clone, Copy)]
pub struct RangeWrapper<R, T>(
pub R,
PhantomData<T>,
)
where
R: RangeBounds<T>;
impl<R, T> RangeWrapper<R, T>
where
R: RangeBounds<T>,
{
#[must_use]
pub fn new(value: R) -> Self {
Self(value, PhantomData)
}
#[must_use]
pub fn from_ref(base: &R) -> &RangeWrapper<R, T> {
unsafe { mem::transmute(base) }
}
}
impl<R, T> RangeWrapper<R, T>
where
R: RangeBounds<T>,
{
#[inline]
#[must_use]
pub fn contains<U>(&self, value: &U) -> bool
where
T: PartialOrd<U>,
U: ?Sized + PartialOrd<T>,
{
RangeBounds::contains(self, value)
}
}
impl<R, T> RangeWrapper<R, T>
where
R: RangeBounds<T>,
{
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::is_empty::top!()]
#[doc = doc_rrb::side::is_empty::sub::examples::head!()]
pub fn is_empty(&self) -> bool
where
T: PartialOrd,
{
RichRangeBounds::is_empty(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::is_broken::top!()]
#[doc = doc_rrb::side::is_broken::sub::examples::head!()]
pub fn is_broken(&self) -> bool
where
T: PartialOrd,
{
RichRangeBounds::is_broken(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::is_cursor::top!()]
#[doc = doc_rrb::side::is_cursor::sub::examples::head!()]
pub fn is_cursor(&self) -> bool
where
T: PartialEq,
{
RichRangeBounds::is_cursor(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::is_cursor_fwd::top!()]
#[doc = doc_rrb::side::is_cursor_fwd::sub::examples::head!()]
pub fn is_cursor_fwd(&self) -> bool
where
T: PartialEq,
{
RichRangeBounds::is_cursor_fwd(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::is_cursor_bwd::top!()]
#[doc = doc_rrb::side::is_cursor_bwd::sub::examples::head!()]
pub fn is_cursor_bwd(&self) -> bool
where
T: PartialEq,
{
RichRangeBounds::is_cursor_bwd(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::is_point::top!()]
#[doc = doc_rrb::side::is_point::sub::examples::head!()]
pub fn is_point(&self) -> bool
where
T: PartialEq,
{
RichRangeBounds::is_point(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::is_wide::top!()]
#[doc = doc_rrb::side::is_wide::sub::examples::head!()]
pub fn is_wide(&self) -> bool
where
T: PartialOrd,
{
RichRangeBounds::is_wide(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::is_full::top!()]
#[doc = doc_rrb::side::is_full::sub::examples::head!()]
pub fn is_full(&self) -> bool
where
T: PartialOrd,
{
RichRangeBounds::is_full(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::start_edge::top!()]
#[doc = doc_rrb::side::start_edge::sub::examples::head!()]
pub fn start_edge(&self) -> Edge<&T> {
RichRangeBounds::start_edge(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::end_edge::top!()]
#[doc = doc_rrb::side::end_edge::sub::examples::head!()]
pub fn end_edge(&self) -> Edge<&T> {
RichRangeBounds::end_edge(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::head::top!()]
#[doc = doc_rrb::side::head::sub::panics::all!()]
#[doc = doc_rrb::side::head::sub::examples::head!()]
pub fn head(&self) -> T
where
T: Clone + HasLimits + HasNexts,
{
RichRangeBounds::head(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::tail::top!()]
#[doc = doc_rrb::side::tail::sub::panics::all!()]
#[doc = doc_rrb::side::tail::sub::examples::head!()]
pub fn tail(&self) -> T
where
T: Clone + HasLimits + HasNexts,
{
RichRangeBounds::tail(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::prev::top!()]
#[doc = doc_rrb::side::prev::sub::panics::all!()]
#[doc = doc_rrb::side::prev::sub::examples::head!()]
pub fn prev(&self) -> T
where
T: Clone + HasLimits + HasNexts,
{
RichRangeBounds::prev(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::next::top!()]
#[doc = doc_rrb::side::next::sub::panics::all!()]
#[doc = doc_rrb::side::next::sub::examples::head!()]
pub fn next(&self) -> T
where
T: Clone + HasLimits + HasNexts,
{
RichRangeBounds::next(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::cursor::top!()]
#[doc = doc_rrb::side::cursor::sub::examples::head!()]
pub fn cursor(&self) -> Option<&T>
where
T: PartialEq,
{
RichRangeBounds::cursor(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::point::top!()]
#[doc = doc_rrb::side::point::sub::examples::head!()]
pub fn point(&self) -> Option<&T>
where
T: PartialEq,
{
RichRangeBounds::point(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::len::top!()]
#[doc = doc_rrb::side::len::sub::groups::all!()]
#[doc = doc_rrb::side::len::sub::examples::head!()]
pub fn len(&self) -> Option<usize>
where
T: Step,
{
RichRangeBounds::len(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::size::top!()]
#[doc = doc_rrb::side::size::sub::panics::all!()]
#[doc = doc_rrb::side::size::sub::groups::all!()]
#[doc = doc_rrb::side::size::sub::examples::head!()]
pub fn size(&self) -> Option<T>
where
T: Step,
for<'a> &'a T: Sub<&'a T, Output = T>,
{
RichRangeBounds::size(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::width::top!()]
#[doc = doc_rrb::side::width::sub::notes::all!()]
#[doc = doc_rrb::side::width::sub::panics::all!()]
#[doc = doc_rrb::side::width::sub::groups::all!()]
#[doc = doc_rrb::side::width::sub::examples::head!()]
pub fn width(&self) -> Option<T>
where
T: PartialOrd,
for<'a> &'a T: Sub<&'a T, Output = T>,
{
RichRangeBounds::width(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::bounds::top!()]
#[doc = doc_rrb::side::bounds::sub::examples::head!()]
pub fn bounds(&self) -> (Bound<&T>, Bound<&T>) {
RichRangeBounds::bounds(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::edges::top!()]
#[doc = doc_rrb::side::edges::sub::examples::head!()]
pub fn edges(&self) -> (Edge<&T>, Edge<&T>) {
RichRangeBounds::edges(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::as_ref::top!()]
#[doc = doc_rrb::side::as_ref::sub::examples::head!()]
pub fn as_ref(&self) -> <Self as RangeSrc<T>>::Range<&T>
where
Self: RangeSrc<T>,
{
RichRangeBounds::as_ref(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::cast::top!()]
#[doc = doc_rrb::side::cast::sub::examples::head!()]
pub fn cast<U>(self) -> <Self as RangeSrc<T>>::Range<U>
where
U: From<T>,
Self: RangeSrc<T> + RangeParts<T>,
{
RichRangeBounds::cast(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::try_cast::top!()]
#[doc = doc_rrb::side::try_cast::sub::examples::head!()]
pub fn try_cast<U>(self) -> Option<<Self as RangeSrc<T>>::Range<U>>
where
U: TryFrom<T>,
Self: RangeSrc<T> + RangeParts<T>,
{
RichRangeBounds::try_cast(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::to_range::top!()]
#[doc = doc_rrb::side::to_range::sub::panics::all!()]
#[doc = doc_rrb::side::to_range::sub::examples::head!()]
pub fn to_range(&self) -> Range<T>
where
T: Clone,
T: HasLimits + HasNexts,
{
RichRangeBounds::to_range(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::into_option::top!()]
#[doc = doc_rrb::side::into_option::sub::examples::head!()]
pub fn into_option(self) -> Option<Self>
where
Self: Sized,
T: PartialOrd,
{
RichRangeBounds::into_option(self)
}
#[inline]
#[doc_on_only]
#[doc = doc_rrb::side::iter::top!()]
#[doc = doc_rrb::side::iter::sub::examples::head!()]
pub fn iter(&self) -> IterRichRange<T>
where
T: Step,
{
RichRangeBounds::iter(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::flip::top!()]
#[doc = doc_rrb::side::flip::sub::notes::all!()]
#[doc = doc_rrb::side::flip::sub::examples::head!()]
pub fn flip(&self) -> (Option<RangeUniv<T>>, Option<RangeUniv<T>>)
where
T: Clone + PartialOrd,
{
RichRangeBounds::flip(self)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::flip_adv::top!()]
#[doc = doc_rrb::side::flip_adv::sub::notes::all!()]
#[doc = doc_rrb::side::flip_adv::sub::examples::head!()]
pub fn flip_adv(&self, mode: CursorMode) -> (Option<RangeUniv<T>>, Option<RangeUniv<T>>)
where
T: Clone + PartialOrd,
{
RichRangeBounds::flip_adv(self, mode)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::shl::top!()]
#[doc = doc_rrb::side::shl::sub::panics::all!()]
#[doc = doc_rrb::side::shl::sub::examples::head!()]
pub fn shl(&self, value: impl Borrow<T>) -> Self
where
T: Sized,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: Sub<&'a T, Output = T>,
{
RichRangeBounds::shl(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::shr::top!()]
#[doc = doc_rrb::side::shr::sub::panics::all!()]
#[doc = doc_rrb::side::shr::sub::examples::head!()]
pub fn shr(&self, value: impl Borrow<T>) -> Self
where
T: Sized,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: Add<&'a T, Output = T>,
{
RichRangeBounds::shr(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::add_start::top!()]
#[doc = doc_rrb::side::add_start::sub::panics::all!()]
#[doc = doc_rrb::side::add_start::sub::examples::head!()]
pub fn add_start(&self, value: impl Borrow<T>) -> Self
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: Add<&'a T, Output = T>,
{
RichRangeBounds::add_start(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::add_end::top!()]
#[doc = doc_rrb::side::add_end::sub::panics::all!()]
#[doc = doc_rrb::side::add_end::sub::examples::head!()]
pub fn add_end(&self, value: impl Borrow<T>) -> Self
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: Add<&'a T, Output = T>,
{
RichRangeBounds::add_end(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::sub_start::top!()]
#[doc = doc_rrb::side::sub_start::sub::panics::all!()]
#[doc = doc_rrb::side::sub_start::sub::examples::head!()]
pub fn sub_start(&self, value: impl Borrow<T>) -> Self
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: Sub<&'a T, Output = T>,
{
RichRangeBounds::sub_start(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::sub_end::top!()]
#[doc = doc_rrb::side::sub_end::sub::panics::all!()]
#[doc = doc_rrb::side::sub_end::sub::examples::head!()]
pub fn sub_end(&self, value: impl Borrow<T>) -> Self
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: Sub<&'a T, Output = T>,
{
RichRangeBounds::sub_end(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::calc_start::top!()]
#[doc = doc_rrb::side::calc_start::sub::panics::all!()]
#[doc = doc_rrb::side::calc_start::sub::examples::head!()]
pub fn calc_start(&self, width: impl Borrow<T>) -> Self
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: Sub<&'a T, Output = T>,
{
RichRangeBounds::calc_start(self, width)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::calc_end::top!()]
#[doc = doc_rrb::side::calc_end::sub::panics::all!()]
#[doc = doc_rrb::side::calc_end::sub::examples::head!()]
pub fn calc_end(&self, width: impl Borrow<T>) -> Self
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: Add<&'a T, Output = T>,
{
RichRangeBounds::calc_end(self, width)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::align_start::top!()]
#[doc = doc_rrb::side::align_start::sub::panics::all!()]
#[doc = doc_rrb::side::align_start::sub::examples::head!()]
pub fn align_start(&self, value: impl Borrow<T>) -> Self
where
T: Clone + PartialOrd,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedAdd<&'a T, Output = T>,
for<'a> &'a T: CheckedSub<&'a T, Output = T>,
{
RichRangeBounds::align_start(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::align_end::top!()]
#[doc = doc_rrb::side::align_end::sub::panics::all!()]
#[doc = doc_rrb::side::align_end::sub::examples::head!()]
pub fn align_end(&self, value: impl Borrow<T>) -> Self
where
T: Clone + PartialOrd,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedAdd<&'a T, Output = T>,
for<'a> &'a T: CheckedSub<&'a T, Output = T>,
{
RichRangeBounds::align_end(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::map::top!()]
#[doc = doc_rrb::side::map::sub::examples::head!()]
pub fn map<F, U>(self, f: F) -> <Self as RangeSrc<T>>::Range<U>
where
F: FnMut(T) -> U,
Self: RangeSrc<T> + RangeParts<T>,
{
RichRangeBounds::map(self, f)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::try_map::top!()]
#[doc = doc_rrb::side::try_map::sub::examples::head!()]
pub fn try_map<F, U>(self, f: F) -> Option<<Self as RangeSrc<T>>::Range<U>>
where
F: FnMut(T) -> Option<U>,
Self: RangeSrc<T> + RangeParts<T>,
{
RichRangeBounds::try_map(self, f)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_shl::top!()]
#[doc = doc_rrb::side::checked_shl::sub::examples::head!()]
pub fn checked_shl(&self, value: impl Borrow<T>) -> Option<Self>
where
T: Sized,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedSub<&'a T, Output = T>,
{
RichRangeBounds::checked_shl(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_shr::top!()]
#[doc = doc_rrb::side::checked_shr::sub::examples::head!()]
pub fn checked_shr(&self, value: impl Borrow<T>) -> Option<Self>
where
T: Sized,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedAdd<&'a T, Output = T>,
{
RichRangeBounds::checked_shr(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_add_start::top!()]
#[doc = doc_rrb::side::checked_add_start::sub::examples::head!()]
pub fn checked_add_start(&self, value: impl Borrow<T>) -> Option<Self>
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedAdd<&'a T, Output = T>,
{
RichRangeBounds::checked_add_start(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_add_end::top!()]
#[doc = doc_rrb::side::checked_add_end::sub::examples::head!()]
pub fn checked_add_end(&self, value: impl Borrow<T>) -> Option<Self>
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedAdd<&'a T, Output = T>,
{
RichRangeBounds::checked_add_end(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_sub_start::top!()]
#[doc = doc_rrb::side::checked_sub_start::sub::examples::head!()]
pub fn checked_sub_start(&self, value: impl Borrow<T>) -> Option<Self>
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedSub<&'a T, Output = T>,
{
RichRangeBounds::checked_sub_start(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_sub_end::top!()]
#[doc = doc_rrb::side::checked_sub_end::sub::examples::head!()]
pub fn checked_sub_end(&self, value: impl Borrow<T>) -> Option<Self>
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedSub<&'a T, Output = T>,
{
RichRangeBounds::checked_sub_end(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_calc_start::top!()]
#[doc = doc_rrb::side::checked_calc_start::sub::panics::all!()]
#[doc = doc_rrb::side::checked_calc_start::sub::examples::head!()]
pub fn checked_calc_start(&self, width: impl Borrow<T>) -> Option<Self>
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedSub<&'a T, Output = T>,
{
RichRangeBounds::checked_calc_start(self, width)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_calc_end::top!()]
#[doc = doc_rrb::side::checked_calc_end::sub::panics::all!()]
#[doc = doc_rrb::side::checked_calc_end::sub::examples::head!()]
pub fn checked_calc_end(&self, width: impl Borrow<T>) -> Option<Self>
where
T: Clone,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedAdd<&'a T, Output = T>,
{
RichRangeBounds::checked_calc_end(self, width)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_align_start::top!()]
#[doc = doc_rrb::side::checked_align_start::sub::panics::all!()]
#[doc = doc_rrb::side::checked_align_start::sub::examples::head!()]
pub fn checked_align_start(&self, value: impl Borrow<T>) -> Option<Self>
where
T: Clone + PartialOrd,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedAdd<&'a T, Output = T>,
for<'a> &'a T: CheckedSub<&'a T, Output = T>,
{
RichRangeBounds::checked_align_start(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::checked_align_end::top!()]
#[doc = doc_rrb::side::checked_align_end::sub::panics::all!()]
#[doc = doc_rrb::side::checked_align_end::sub::examples::head!()]
pub fn checked_align_end(&self, value: impl Borrow<T>) -> Option<Self>
where
T: Clone + PartialOrd,
Self: RangeSrc<T, Range<T> = Self>,
for<'a> &'a T: CheckedAdd<&'a T, Output = T>,
for<'a> &'a T: CheckedSub<&'a T, Output = T>,
{
RichRangeBounds::checked_align_end(self, value)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::equiv::top!()]
#[doc = doc_rrb::side::equiv::sub::examples::head!()]
pub fn equiv<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::equiv(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::intersects::top!()]
#[doc = doc_rrb::side::intersects::sub::notes::all!()]
#[doc = doc_rrb::side::intersects::sub::examples::head!()]
pub fn intersects<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::intersects(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::includes::top!()]
#[doc = doc_rrb::side::includes::sub::notes::all!()]
#[doc = doc_rrb::side::includes::sub::examples::head!()]
pub fn includes<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::includes(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::included::top!()]
#[doc = doc_rrb::side::included::sub::notes::all!()]
#[doc = doc_rrb::side::included::sub::examples::head!()]
pub fn included<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::included(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::adjoins::top!()]
#[doc = doc_rrb::side::adjoins::sub::notes::all!()]
#[doc = doc_rrb::side::adjoins::sub::groups::all!()]
#[doc = doc_rrb::side::adjoins::sub::examples::head!()]
pub fn adjoins<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::adjoins(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::adjoins_prev::top!()]
#[doc = doc_rrb::side::adjoins_prev::sub::notes::all!()]
#[doc = doc_rrb::side::adjoins_prev::sub::groups::all!()]
#[doc = doc_rrb::side::adjoins_prev::sub::examples::head!()]
pub fn adjoins_prev<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::adjoins_prev(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::adjoins_next::top!()]
#[doc = doc_rrb::side::adjoins_next::sub::notes::all!()]
#[doc = doc_rrb::side::adjoins_next::sub::groups::all!()]
#[doc = doc_rrb::side::adjoins_next::sub::examples::head!()]
pub fn adjoins_next<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::adjoins_next(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::touches::top!()]
#[doc = doc_rrb::side::touches::sub::notes::all!()]
#[doc = doc_rrb::side::touches::sub::groups::all!()]
#[doc = doc_rrb::side::touches::sub::examples::head!()]
pub fn touches<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::touches(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::touches_prev::top!()]
#[doc = doc_rrb::side::touches_prev::sub::notes::all!()]
#[doc = doc_rrb::side::touches_prev::sub::groups::all!()]
#[doc = doc_rrb::side::touches_prev::sub::examples::head!()]
pub fn touches_prev<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::touches_prev(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::touches_next::top!()]
#[doc = doc_rrb::side::touches_next::sub::notes::all!()]
#[doc = doc_rrb::side::touches_next::sub::groups::all!()]
#[doc = doc_rrb::side::touches_next::sub::examples::head!()]
pub fn touches_next<R2>(&self, other: &R2) -> bool
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::touches_next(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::rel::top!()]
#[doc = doc_rrb::side::rel::sub::examples::head!()]
pub fn rel<R2>(&self, other: &R2, ps: PosStyle) -> RangeRel
where
R2: ?Sized + RangeBounds<T>,
T: PartialOrd,
{
RichRangeBounds::rel(self, other, ps)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::cut::top!()]
#[doc = doc_rrb::side::cut::sub::notes::all!()]
#[doc = doc_rrb::side::cut::sub::examples::head!()]
pub fn cut(&self, pos: &T, mode: CutMode) -> (Option<RangeUniv<T>>, Option<RangeUniv<T>>)
where
T: Clone + PartialOrd,
{
RichRangeBounds::cut(self, pos, mode)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::interval::top!()]
#[doc = doc_rrb::side::interval::sub::panics::all!()]
#[doc = doc_rrb::side::interval::sub::examples::head!()]
pub fn interval(&self, other: &Self) -> Option<RangeUniv<T>>
where
T: Clone + PartialOrd,
{
RichRangeBounds::interval(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::interval_adv::top!()]
#[doc = doc_rrb::side::interval_adv::sub::panics::all!()]
#[doc = doc_rrb::side::interval_adv::sub::examples::head!()]
pub fn interval_adv(&self, other: &Self, mode: CursorMode) -> Option<RangeUniv<T>>
where
T: Clone + PartialOrd,
{
RichRangeBounds::interval_adv(self, other, mode)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::prod::top!()]
#[doc = doc_rrb::side::prod::sub::notes::all!()]
#[doc = doc_rrb::side::prod::sub::panics::all!()]
#[doc = doc_rrb::side::prod::sub::examples::head!()]
pub fn prod(&self, other: &Self) -> Option<Self>
where
Self: RangeSrc<T, Range<T> = Self>,
T: Clone + PartialOrd,
{
RichRangeBounds::prod(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::enwrap::top!()]
#[doc = doc_rrb::side::enwrap::sub::notes::all!()]
#[doc = doc_rrb::side::enwrap::sub::panics::all!()]
#[doc = doc_rrb::side::enwrap::sub::examples::head!()]
pub fn enwrap(&self, other: &Self) -> Option<Self>
where
Self: RangeSrc<T, Range<T> = Self>,
T: Clone + PartialOrd,
{
RichRangeBounds::enwrap(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::union::top!()]
#[doc = doc_rrb::side::union::sub::notes::all!()]
#[doc = doc_rrb::side::union::sub::panics::all!()]
#[doc = doc_rrb::side::union::sub::examples::head!()]
pub fn union(&self, other: &Self) -> (Self, Option<Self>)
where
Self: RangeSrc<T, Range<T> = Self>,
T: Clone + PartialOrd,
{
RichRangeBounds::union(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::diff::top!()]
#[doc = doc_rrb::side::diff::sub::notes::all!()]
#[doc = doc_rrb::side::diff::sub::panics::all!()]
#[doc = doc_rrb::side::diff::sub::examples::head!()]
pub fn diff<R2>(&self, other: &R2) -> (Option<RangeUniv<T>>, Option<RangeUniv<T>>)
where
R2: RangeBounds<T>,
T: Clone + PartialOrd,
{
RichRangeBounds::diff(self, other)
}
#[inline]
#[must_use]
#[doc_on_only]
#[doc = doc_rrb::side::diff_adv::top!()]
#[doc = doc_rrb::side::diff_adv::sub::notes::all!()]
#[doc = doc_rrb::side::diff_adv::sub::panics::all!()]
#[doc = doc_rrb::side::diff_adv::sub::examples::head!()]
pub fn diff_adv<R2>(
&self,
other: &R2,
mode: CursorMode,
) -> (Option<RangeUniv<T>>, Option<RangeUniv<T>>)
where
R2: RangeBounds<T>,
T: Clone + PartialOrd,
{
RichRangeBounds::diff_adv(self, other, mode)
}
}
impl<R, T> RangeBounds<T> for RangeWrapper<R, T>
where
R: RangeBounds<T>,
{
#[inline]
fn start_bound(&self) -> Bound<&T> {
self.0.start_bound()
}
#[inline]
fn end_bound(&self) -> Bound<&T> {
self.0.end_bound()
}
}
impl<R, T> RichRangeBounds<T> for RangeWrapper<R, T>
where
R: RangeBounds<T>,
{
}
impl<R, T> IntoIterator for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Step,
{
type Item = T;
type IntoIter = IterRichRange<T>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
impl<R, T> Eq for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Eq,
{
}
impl<R, T> PartialEq for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: PartialEq,
{
fn eq(&self, other: &Self) -> bool {
calc::is_eq(self, other)
}
}
impl<R, T> PartialOrd for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: PartialOrd,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
calc::cmp(self, other)
}
}
macro_rules! impl_shl {
(($($lhsRef:tt)?) ($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> Shl<$($rhsRef)?T> for $($lhsRef)?RangeWrapper<R, T>
where
R: RangeBounds<T>,
for<'a> &'a T: Sub<&'a T, Output = T>,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
type Output = RangeWrapper<R, T>;
$(
#[$main]
/// Performs the `<<` operation.
/// <a id="main_shl" style="visibility:hidden;"></a>
///
/// Returns a new range with both ends subtracted by given value.
///
/// # Panics
///
/// Panics if position of the bound is overflowed.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// assert_eq!(rw::new(30..60) << 10, rw::new(20..50));
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::shl).
)?
fn shl(self, rhs: $($rhsRef)?T) -> Self::Output {
calc::shl(util::to_ref!($($lhsRef)?, self), rhs)
}
}
}
}
macro_rules! impl_shr {
(($($lhsRef:tt)?) ($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> Shr<$($rhsRef)?T> for $($lhsRef)?RangeWrapper<R, T>
where
R: RangeBounds<T>,
for<'a> &'a T: Add<&'a T, Output = T>,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
type Output = RangeWrapper<R, T>;
$(
#[$main]
/// Performs the `>>` operation.
/// <a id="main_shr" style="visibility:hidden;"></a>
///
/// Returns a new range with both ends added by given value.
///
/// # Panics
///
/// Panics if position of the bound is overflowed.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// assert_eq!(rw::new(30..60) >> 10, rw::new(40..70));
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::shr).
)?
fn shr(self, rhs: $($rhsRef)?T) -> Self::Output {
calc::shr(util::to_ref!($($lhsRef)?, self), rhs)
}
}
}
}
macro_rules! impl_bitand {
(($($lhsRef:tt)?) ($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> BitAnd<$($rhsRef)?RangeWrapper<R, T>> for $($lhsRef)?RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Clone + PartialOrd + HasLimits,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
type Output = RangeWrapper<R, T>;
$(
#[$main]
/// Performs the `&` operation.
///
/// Returns the shared range of two ranges.
///
/// # Notes
///
/// If two range has no intersection, returns [broken empty][eh].
///
/// [eh]: crate::RichRangeBounds#empty-handling
///
/// # Panics
///
/// Panics if range has unordered position like NaN.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// assert_eq!(rw::new(30..60) & rw::new(40..70), rw::new(40..60));
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::bitand).
)?
fn bitand(self, rhs: $($rhsRef)?RangeWrapper<R, T>) -> Self::Output {
let rx = util::to_ref!($($lhsRef)?, self);
let ry = util::to_ref!($($rhsRef)?, rhs);
calc::closed_prod(rx, ry)
}
}
}
}
macro_rules! impl_bitor {
(($($lhsRef:tt)?) ($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> BitOr<$($rhsRef)?RangeWrapper<R, T>> for $($lhsRef)?RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Clone + PartialOrd,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
type Output = RangeWrapper<R, T>;
$(
#[$main]
/// Performs the `|` operation.
///
/// Returns the merged ranges of two ranges.
///
/// # Panics
///
/// Panics if range has unordered position like NaN.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// assert_eq!(rw::new(30..60) | rw::new(40..70), rw::new(30..70));
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::bitor).
)?
fn bitor(self, rhs: $($rhsRef)?RangeWrapper<R, T>) -> Self::Output {
let rx = util::to_ref!($($lhsRef)?, self);
let ry = util::to_ref!($($rhsRef)?, rhs);
calc::closed_union(rx, ry)
}
}
}
}
macro_rules! impl_bitxor {
(($($lhsRef:tt)?) ($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> BitXor<$($rhsRef)?RangeWrapper<R, T>> for $($lhsRef)?RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Clone + PartialOrd + HasLimits,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
type Output = RangeWrapper<R, T>;
$(
#[$main]
/// Performs the `^` operation.
///
/// Returns the super range of two ranges.
///
/// # Note
///
/// - Both range is empty, returns [broken empty][eh].
/// - One range is empty, returns the other range.
///
/// [eh]: crate::RichRangeBounds#empty-handling
///
/// # Panics
///
/// Panics if range has unordered position like NaN.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
/// use std::ops::Range;
///
/// assert_eq!(rw::new(30..40) ^ rw::new(60..70), rw::new(30..70));
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::bitxor).
)?
fn bitxor(self, rhs: $($rhsRef)?RangeWrapper<R, T>) -> Self::Output {
let rx = util::to_ref!($($lhsRef)?, self);
let ry = util::to_ref!($($rhsRef)?, rhs);
calc::closed_enwrap(rx, ry)
}
}
}
}
macro_rules! impl_shl_assign {
(($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> ShlAssign<$($rhsRef)?T> for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Clone,
for<'a> &'a T: Sub<&'a T, Output = T>,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
$(
#[$main]
/// Performs the `<<=` operation.
/// <a id="main_shl_assign" style="visibility:hidden;"></a>
///
/// Assigns range with both ends subtracted by given value.
///
/// # Panics
///
/// Panics if position of the bound is overflowed.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// let mut r = rw::new(30..60);
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::shl_assign).
)?
fn shl_assign(&mut self, rhs: $($rhsRef)?T) {
*self = calc::shl(self, rhs);
}
}
}
}
macro_rules! impl_shr_assign {
(($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> ShrAssign<$($rhsRef)?T> for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Clone,
for<'a> &'a T: Add<&'a T, Output = T>,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
$(
#[$main]
/// Performs the `>>=` operation.
/// <a id="main_shr_assign" style="visibility:hidden;"></a>
///
/// Assigns range with both ends subtracted by given value.
///
/// # Panics
///
/// Panics if position of the bound is overflowed.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// let mut r = rw::new(30..60);
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::shr_assign).
)?
fn shr_assign(&mut self, rhs: $($rhsRef)?T) {
*self = calc::shr(self, rhs);
}
}
}
}
macro_rules! impl_bitand_assign {
(($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> BitAndAssign<$($rhsRef)?RangeWrapper<R, T>> for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Clone + PartialOrd + HasLimits,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
$(
#[$main]
/// Performs the `&=` operation.
///
/// Assigns shared range of two ranges.
///
/// # Notes
///
/// If two range has no intersection, assigns [broken empty][eh].
///
/// [eh]: crate::RichRangeBounds#empty-handling
///
/// # Panics
///
/// Panics if the range has unordered position like NaN.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// let mut r = rw::new(30..60);
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::bitand_assign).
)?
fn bitand_assign(&mut self, rhs: $($rhsRef)?RangeWrapper<R, T>) {
*self = calc::closed_prod(self, &rhs);
}
}
}
}
macro_rules! impl_bitor_assign {
(($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> BitOrAssign<$($rhsRef)?RangeWrapper<R, T>> for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Clone + PartialOrd,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
$(
#[$main]
/// Performs the `|=` operation.
///
/// Assigns merged range of two ranges.
///
/// # Panics
///
/// Panics if the range has unordered position like NaN.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// let mut r = rw::new(30..60);
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::bitor_assign).
)?
fn bitor_assign(&mut self, rhs: $($rhsRef)?RangeWrapper<R, T>) {
*self = calc::closed_union(self, &rhs);
}
}
}
}
macro_rules! impl_bitxor_assign {
(($($rhsRef:tt)?) $(, main:$main:meta)? $(, sub:$sub:meta)?) => {
impl<R, T> BitXorAssign<$($rhsRef)?RangeWrapper<R, T>> for RangeWrapper<R, T>
where
R: RangeBounds<T>,
T: Clone + PartialOrd + HasLimits,
RangeWrapper<R, T>: RangeSrc<T, Range<T> = RangeWrapper<R, T>>,
{
$(
#[$main]
/// Performs the `^=` operation.
///
/// Assigns super range of two ranges.
///
/// # Note
///
/// - Both range is empty, assigns [broken empty][eh].
/// - One range is empty, assigns the other range.
///
/// [eh]: crate::RichRangeBounds#empty-handling
///
/// # Panics
///
/// Panics if the range has unordered position like NaN.
///
/// # Examples
///
/// ```
/// use rich_range::prelude::*;
///
/// let mut r = rw::new(30..40);
)?
$(
#[$sub]
/// See main overload [document](RangeUniv::bitxor_assign).
)?
fn bitxor_assign(&mut self, rhs: $($rhsRef)?RangeWrapper<R, T>) {
*self = calc::closed_enwrap(self, &rhs);
}
}
}
}
impl_shl!(() (), main:doc = "");
impl_shl!(() (&), sub:doc = "");
impl_shl!((&) (), sub:doc = "");
impl_shl!((&) (&), sub:doc = "");
impl_shr!(() (), main:doc = "");
impl_shr!(() (&), sub:doc = "");
impl_shr!((&) (), sub:doc = "");
impl_shr!((&) (&), sub:doc = "");
impl_bitand!(() (), main:doc = "");
impl_bitand!(() (&), sub:doc = "");
impl_bitand!((&) (), sub:doc = "");
impl_bitand!((&) (&), sub:doc = "");
impl_bitor!(() (), main:doc = "");
impl_bitor!(() (&), sub:doc = "");
impl_bitor!((&) (), sub:doc = "");
impl_bitor!((&) (&), sub:doc = "");
impl_bitxor!(() (), main:doc = "");
impl_bitxor!(() (&), sub:doc = "");
impl_bitxor!((&) (), sub:doc = "");
impl_bitxor!((&) (&), sub:doc = "");
impl_shl_assign!((), main:doc = "");
impl_shl_assign!((&), sub:doc = "");
impl_shr_assign!((), main:doc = "");
impl_shr_assign!((&), sub:doc = "");
impl_bitand_assign!((), main:doc = "");
impl_bitand_assign!((&), sub:doc = "");
impl_bitor_assign!((), main:doc = "");
impl_bitor_assign!((&), sub:doc = "");
impl_bitxor_assign!((), main:doc = "");
impl_bitxor_assign!((&), sub:doc = "");