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 where
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,
pub fn contains<U>(&self, item: &U) -> bool where
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
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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more