pub struct Interval<N>(/* private fields */)
where
N: Ord + Clone;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) -> bool
pub fn contains<U>(&self, item: &U) -> bool
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§
Source§impl<N> Deref for Interval<N>
Use the Deref operator to get a reference to Range wrapped by the Interval newtype.
impl<N> Deref for Interval<N>
Use the Deref operator to get a reference to Range wrapped by the Interval newtype.
Source§impl<'de, N> Deserialize<'de> for Interval<N>
impl<'de, N> Deserialize<'de> for Interval<N>
Source§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
Source§impl<'a, N> From<&'a Range<N>> for Interval<N>
Convert a reference to a Range to an interval by cloning. This conversion will panic if the
Range has end < start
impl<'a, N> From<&'a Range<N>> for Interval<N>
Convert a reference to a Range to an interval by cloning. This conversion will panic if the
Range has end < start
Source§impl<N> From<Range<N>> for Interval<N>
Convert a Range into an Interval. This conversion will panic if the Range has end < start
impl<N> From<Range<N>> for Interval<N>
Convert a Range into an Interval. This conversion will panic if the Range has end < start
Source§impl<N> Serialize for Interval<N>
impl<N> Serialize for Interval<N>
Source§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>
impl<N> StructuralPartialEq for Interval<N>
Auto Trait Implementations§
impl<N> Freeze for Interval<N>where
N: Freeze,
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§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.