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]

Construct a new Interval from the given Range. Will return Err if end < start.

Methods from Deref<Target=Range<N>>

🔬 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));
}

🔬 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]

Formats the value using the given formatter.

impl<N: Clone + Ord + Clone> Clone for Interval<N>
[src]

Returns a copy of the value. Read more

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]

This method tests for self and other values to be equal, and is used by ==. Read more

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

Performs the conversion.

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

Performs the conversion.

impl<N: Ord + Clone> Deref for Interval<N>
[src]

Use the Deref operator to get a reference to Range wrapped by the Interval newtype.

The resulting type after dereferencing

The method called to dereference a value