pub enum AnyRange<T: Clone + PartialOrd + PartialEq> {
Range(Range<T>),
RangeFrom(RangeFrom<T>),
RangeFull(RangeFull),
RangeInclusive(RangeInclusive<T>),
RangeTo(RangeTo<T>),
RangeToInclusive(RangeToInclusive<T>),
}
Expand description
An enum that can hold any Range* type.
§Example
use any_range::AnyRange;
let r = AnyRange::from(3..5);
assert!(r.contains(&3));
assert_eq!("de", &"abcdefg"[r.bounds()]);
Variants§
Range(Range<T>)
RangeFrom(RangeFrom<T>)
RangeFull(RangeFull)
RangeInclusive(RangeInclusive<T>)
RangeTo(RangeTo<T>)
RangeToInclusive(RangeToInclusive<T>)
Implementations§
source§impl<T: Clone + PartialOrd + PartialEq> AnyRange<T>
impl<T: Clone + PartialOrd + PartialEq> AnyRange<T>
Trait Implementations§
source§impl<T: Clone + PartialOrd + PartialEq> From<RangeInclusive<T>> for AnyRange<T>
impl<T: Clone + PartialOrd + PartialEq> From<RangeInclusive<T>> for AnyRange<T>
source§fn from(r: RangeInclusive<T>) -> Self
fn from(r: RangeInclusive<T>) -> Self
Converts to this type from the input type.
source§impl<T: Clone + PartialOrd + PartialEq> From<RangeToInclusive<T>> for AnyRange<T>
impl<T: Clone + PartialOrd + PartialEq> From<RangeToInclusive<T>> for AnyRange<T>
source§fn from(r: RangeToInclusive<T>) -> Self
fn from(r: RangeToInclusive<T>) -> Self
Converts to this type from the input type.
source§impl<T: Clone + PartialOrd + PartialEq + Eq + Debug> Ord for AnyRange<T>
impl<T: Clone + PartialOrd + PartialEq + Eq + Debug> Ord for AnyRange<T>
source§impl<T: PartialEq + Clone + PartialOrd + PartialEq> PartialEq for AnyRange<T>
impl<T: PartialEq + Clone + PartialOrd + PartialEq> PartialEq for AnyRange<T>
source§impl<T: Clone + PartialOrd + PartialEq + Debug> PartialOrd for AnyRange<T>
impl<T: Clone + PartialOrd + PartialEq + Debug> PartialOrd for AnyRange<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<T: Clone + PartialOrd + PartialEq> RangeBounds<T> for AnyRange<T>
impl<T: Clone + PartialOrd + PartialEq> RangeBounds<T> for AnyRange<T>
impl<T: Eq + Clone + PartialOrd + PartialEq> Eq for AnyRange<T>
impl<T: Clone + PartialOrd + PartialEq> StructuralPartialEq for AnyRange<T>
Auto Trait Implementations§
impl<T> Freeze for AnyRange<T>where
T: Freeze,
impl<T> RefUnwindSafe for AnyRange<T>where
T: RefUnwindSafe,
impl<T> Send for AnyRange<T>where
T: Send,
impl<T> Sync for AnyRange<T>where
T: Sync,
impl<T> Unpin for AnyRange<T>where
T: Unpin,
impl<T> UnwindSafe for AnyRange<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more