Struct bio::utils::Interval
[−]
[src]
pub struct Interval<N: Ord + Clone>(_);
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]
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>>
fn contains(&self, item: Idx) -> bool
🔬 This is a nightly-only experimental API. (range_contains
)
recently added as per RFC
Examples
#![feature(range_contains)] fn main() { 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)); }
fn step_by(self, by: A) -> StepBy<A, Range<A>>
🔬 This is a nightly-only experimental API. (step_by
)
recent addition
Creates an iterator with the same range, but stepping by the given amount at each iteration.
The resulting iterator handles overflow by stopping.
Examples
#![feature(step_by)] fn main() { let result: Vec<_> = (0..10).step_by(2).collect(); assert_eq!(result, vec![0, 2, 4, 6, 8]); }
Trait Implementations
impl<N: Debug + Ord + Clone> Debug for Interval<N>
[src]
impl<N: Clone + Ord + Clone> Clone for 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
Performs copy-assignment from source
. Read more
impl<N: Eq + Ord + Clone> Eq for Interval<N>
[src]
impl<N: PartialEq + Ord + Clone> PartialEq for Interval<N>
[src]
fn eq(&self, __arg_0: &Interval<N>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Interval<N>) -> bool
This method tests for !=
.
impl<N: Ord + Clone> From<Range<N>> for Interval<N>
[src]
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]
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]
Use the Deref
operator to get a reference to Range
wrapped by the Interval
newtype.