[][src]Struct bio::utils::Interval

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.

Implementations

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

pub fn new(r: Range<N>) -> Result<Interval<N>, Error>[src]

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
1.35.0[src]

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

pub fn is_empty(&self) -> bool[src]

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

assert!(!(3.0..5.0).is_empty());
assert!( (3.0..f32::NAN).is_empty());
assert!( (f32::NAN..5.0).is_empty());

Trait Implementations

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

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

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

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

type Target = Range<N>

The resulting type after dereferencing.

impl<'de, N: Ord + Clone> Deserialize<'de> for Interval<N> where
    N: Deserialize<'de>, 
[src]

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

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> From<Range<N>> for Interval<N>[src]

Convert a Range into an Interval. This conversion will panic if the Range has end < start

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

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

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

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,