Struct bio::utils::Interval [−][src]
An Interval
wraps the std::ops::Range
from the stdlib and is defined by a start and end field
where end should be >= start.
Methods
impl<N: Ord + Clone> Interval<N>
[src]
impl<N: Ord + Clone> Interval<N>
pub fn new(r: Range<N>) -> Result<Interval<N>, IntervalError>
[src]
pub fn new(r: Range<N>) -> Result<Interval<N>, IntervalError>
Construct a new Interval
from the given Range.
Will return Err
if end < start.
Methods from Deref<Target = Range<N>>
pub fn contains<U>(&self, item: &U) -> bool where
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,
[src]
pub fn contains<U>(&self, item: &U) -> bool where
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,
🔬 This is a nightly-only experimental API. (range_contains
)
recently added as per RFC
Returns true
if item
is contained in the range.
Examples
#![feature(range_contains)] use std::f32; 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));
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
🔬 This is a nightly-only experimental API. (range_is_empty
)
recently added
Returns true
if the range contains no items.
Examples
#![feature(range_is_empty)] assert!(!(3..5).is_empty()); assert!( (3..3).is_empty()); assert!( (3..2).is_empty());
The range is empty if either side is incomparable:
#![feature(range_is_empty)] use std::f32::NAN; assert!(!(3.0..5.0).is_empty()); assert!( (3.0..NAN).is_empty()); assert!( (NAN..5.0).is_empty());
Trait Implementations
impl<N: Debug + Ord + Clone> Debug for Interval<N>
[src]
impl<N: Debug + Ord + Clone> Debug for Interval<N>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<N: Clone + Ord + Clone> Clone for Interval<N>
[src]
impl<N: Clone + Ord + Clone> Clone for Interval<N>
fn clone(&self) -> Interval<N>
[src]
fn clone(&self) -> Interval<N>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<N: Eq + Ord + Clone> Eq for Interval<N>
[src]
impl<N: Eq + Ord + Clone> Eq for Interval<N>
impl<N: PartialEq + Ord + Clone> PartialEq for Interval<N>
[src]
impl<N: PartialEq + Ord + Clone> PartialEq for Interval<N>
fn eq(&self, other: &Interval<N>) -> bool
[src]
fn eq(&self, other: &Interval<N>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Interval<N>) -> bool
[src]
fn ne(&self, other: &Interval<N>) -> bool
This method tests for !=
.
impl<N: Ord + Clone> From<Range<N>> for Interval<N>
[src]
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<'a, N: Ord + Clone> From<&'a Range<N>> for Interval<N>
[src]
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
impl<N: Ord + Clone> Deref for Interval<N>
[src]
impl<N: Ord + Clone> Deref for Interval<N>
Use the Deref
operator to get a reference to Range
wrapped by the Interval
newtype.