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
sourceimpl<N: Ord + Clone> Deref for Interval<N>
impl<N: Ord + Clone> Deref for Interval<N>
Use the Deref
operator to get a reference to Range
wrapped by the Interval
newtype.
sourceimpl<'de, N: Ord + Clone> Deserialize<'de> for Interval<N>where
N: Deserialize<'de>,
impl<'de, N: Ord + Clone> Deserialize<'de> for Interval<N>where
N: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'a, N: Ord + Clone> From<&'a Range<N>> for Interval<N>
impl<'a, N: Ord + Clone> 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
sourceimpl<N: Ord + Clone> From<Range<N>> for Interval<N>
impl<N: Ord + Clone> From<Range<N>> for Interval<N>
Convert a Range
into an Interval
. This conversion will panic if the Range
has end < start
sourceimpl<N: PartialEq + Ord + Clone> PartialEq<Interval<N>> for Interval<N>
impl<N: PartialEq + Ord + Clone> PartialEq<Interval<N>> for Interval<N>
impl<N: Eq + Ord + Clone> Eq for Interval<N>
impl<N: Ord + Clone> StructuralEq for Interval<N>
impl<N: Ord + Clone> StructuralPartialEq for Interval<N>
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