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

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

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

Formats the value using the given formatter. Read more

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.

Dereferences the value.

Auto Trait Implementations

impl<N> Send for Interval<N> where
    N: Send

impl<N> Sync for Interval<N> where
    N: Sync