Expand description
An Interval wraps the std::ops::Range from the stdlib and is defined by a start and end field
where end should be >= start.
Implementations
Methods from Deref<Target = Range<N>>
1.35.0 · sourcepub fn contains<U>(&self, item: &U) -> boolwhere
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,
pub fn contains<U>(&self, item: &U) -> boolwhere
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,
Returns true if item is contained in the range.
Examples
assert!(!(3..5).contains(&2));
assert!( (3..5).contains(&3));
assert!( (3..5).contains(&4));
assert!(!(3..5).contains(&5));
assert!(!(3..3).contains(&3));
assert!(!(3..2).contains(&3));
assert!( (0.0..1.0).contains(&0.5));
assert!(!(0.0..1.0).contains(&f32::NAN));
assert!(!(0.0..f32::NAN).contains(&0.5));
assert!(!(f32::NAN..1.0).contains(&0.5));1.47.0 · sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the range contains no items.
Examples
assert!(!(3..5).is_empty());
assert!( (3..3).is_empty());
assert!( (3..2).is_empty());The range is empty if either side is incomparable:
assert!(!(3.0..5.0).is_empty());
assert!( (3.0..f32::NAN).is_empty());
assert!( (f32::NAN..5.0).is_empty());Trait Implementations
impl<N> Deref for Interval<N>where
N: Ord + Clone,
impl<N> Deref for Interval<N>where
N: Ord + Clone,
Use the Deref operator to get a reference to Range wrapped by the Interval newtype.
impl<'de, N> Deserialize<'de> for Interval<N>where
N: Ord + Clone + Deserialize<'de>,
impl<'de, N> Deserialize<'de> for Interval<N>where
N: Ord + Clone + Deserialize<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Interval<N>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Interval<N>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<'a, N> From<&'a Range<N>> for Interval<N>where
N: Ord + Clone,
impl<'a, N> From<&'a Range<N>> for Interval<N>where
N: Ord + Clone,
Convert a reference to a Range to an interval by cloning. This conversion will panic if the
Range has end < start
impl<N> From<Range<N>> for Interval<N>where
N: Ord + Clone,
impl<N> From<Range<N>> for Interval<N>where
N: Ord + Clone,
Convert a Range into an Interval. This conversion will panic if the Range has end < start
impl<N> PartialEq<Interval<N>> for Interval<N>where
N: PartialEq<N> + Ord + Clone,
impl<N> PartialEq<Interval<N>> for Interval<N>where
N: PartialEq<N> + Ord + Clone,
impl<N> Serialize for Interval<N>where
N: Ord + Clone + Serialize,
impl<N> Serialize for Interval<N>where
N: Ord + Clone + Serialize,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<N> Eq for Interval<N>where
N: Eq + Ord + Clone,
impl<N> StructuralEq for Interval<N>where
N: Ord + Clone,
impl<N> StructuralPartialEq for Interval<N>where
N: Ord + Clone,
Auto Trait Implementations
impl<N> RefUnwindSafe for Interval<N>where
N: RefUnwindSafe,
impl<N> Send for Interval<N>where
N: Send,
impl<N> Sync for Interval<N>where
N: Sync,
impl<N> Unpin for Interval<N>where
N: Unpin,
impl<N> UnwindSafe for Interval<N>where
N: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.