Struct bio::utils::Interval

source ·
pub struct Interval<N: Ord + Clone>(_);
Expand description

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

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

Methods from Deref<Target = Range<N>>

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

Returns true if the range contains no items.

Examples
assert!(!(3..5).is_empty());
assert!( (3..3).is_empty());
assert!( (3..2).is_empty());

The range is empty if either side is incomparable:

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

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

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

The resulting type after dereferencing.
Dereferences the value.
Deserialize this value from the given Serde deserializer. Read more

Convert a reference to a Range to an interval by cloning. This conversion will panic if the Range has end < start

Converts to this type from the input type.

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

Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.