Range

Enum Range 

Source
pub enum Range<A = i32> {
    Single(A),
    Bounded(A, A),
    UnboundedL(A),
    UnboundedR(A),
    Unbounded,
}

Variants§

§

Single(A)

§

Bounded(A, A)

§

UnboundedL(A)

§

UnboundedR(A)

§

Unbounded

Implementations§

Source§

impl<A> Range<A>

Source

pub fn is_lower_or_upper_bounded(&self) -> bool

Whether the range is bounded on either side. A bounded range may still be infinite. See also: Range::is_finite.

Source

pub fn is_unbounded(&self) -> bool

Whether the range is unbounded on both sides.

Source

pub fn is_finite(&self) -> bool

Whether the range is finite. See also: Range::is_lower_or_upper_bounded.

Source§

impl<A: Ord> Range<A>

Source

pub fn contains(&self, val: &A) -> bool

Source

pub fn low(&self) -> Option<&A>

Returns the lower bound of the range, if it has one

Source

pub fn high(&self) -> Option<&A>

Returns the upper bound of the range, if it has one

Source§

impl<A: Ord + Clone> Range<A>

Source

pub fn new(lo: Option<A>, hi: Option<A>) -> Range<A>

Create a new range with a lower and upper bound

Source

pub fn spanning(rngs: &[Range<A>]) -> Range<A>

Given a slice of ranges, create a single range that spans from the start of the leftmost range to the end of the rightmost range. An empty slice is considered equivalent to Range::unbounded.

Source§

impl<A: Num + Ord + Clone> Range<A>

Source

pub fn length(&self) -> Option<A>

Source

pub fn overlaps(&self, other: &Range<A>) -> bool

Returns true if this interval overlaps another one, i.e. at least one number is part of both self and other E.g:

  • [0, 2] overlaps [2, 4]
  • [1, 3] overlaps [2, 4]
  • [4, 6] overlaps [2, 4]
Source

pub fn touches_left(&self, other: &Range<A>) -> bool

Returns true if this interval touches another one on the left E.g: [1, 2] touches_left [3, 4]

Source

pub fn touches_right(&self, other: &Range<A>) -> bool

Returns true if this interval touches another one on the right E.g: [3, 4] touches_right [1, 2]

Source

pub fn joins(&self, other: &Range<A>) -> bool

Returns true if this interval overlaps or touches another one E.g:

  • [1, 3] joins [4, 6]
  • [2, 4] joins [4, 6]
  • [3, 5] joins [4, 6]
  • [6, 8] joins [4, 6]
  • [7, 8] joins [4, 6]
Source

pub fn is_before(&self, other: &Range<A>) -> bool

Returns true if this interval is strictly before another one

Source

pub fn is_after(&self, other: &Range<A>) -> bool

Returns true if this interval is strictly after another one

Source

pub fn join(&self, other: &Range<A>) -> Option<Range<A>>

If the two ranges join, return a new range which spans both

Source

pub fn squeeze(rngs: &[Range<A>]) -> Vec<Range<A>>

Merge all joining ranges in the list, and return a new vec of disjoint ranges. E.g:

[(2..3), (4), (..1), (6..8)] -> [(..4), (6..8)]
§Performance

Currently uses a naive O(n^2) algorithm. A more optimal approach based on interval trees is planned.

Source

pub fn iter(&self) -> Option<RangeIterator<A>>

If this range is bounded, returns a lazy iterator over all values within the range. Otherwise, returns None.

Source

pub fn values(rngs: &[Range<A>]) -> Option<impl Iterator<Item = A>>

Source§

impl Range<IntVal>

Source

pub fn resolve(&self) -> Option<Range<i32>>

Trait Implementations§

Source§

impl<A: Clone> Clone for Range<A>

Source§

fn clone(&self) -> Range<A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug> Debug for Range<A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, A> Deserialize<'de> for Range<A>
where A: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<A: Display> Display for Range<A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Range> for Range<IntVal>

Source§

fn from(value: Range<i32>) -> Self

Converts to this type from the input type.
Source§

impl<A: Hash> Hash for Range<A>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<A: PartialEq> PartialEq for Range<A>

Source§

fn eq(&self, other: &Range<A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A> Quine for Range<A>
where A: Quine,

Source§

impl<A> Serialize for Range<A>
where A: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryInto<Range> for Range<IntVal>

Source§

type Error = DomainOpError

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<Range<i32>, Self::Error>

Performs the conversion.
Source§

impl<A: Eq> Eq for Range<A>

Source§

impl<A> StructuralPartialEq for Range<A>

Auto Trait Implementations§

§

impl<A> Freeze for Range<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for Range<A>
where A: RefUnwindSafe,

§

impl<A> Send for Range<A>
where A: Send,

§

impl<A> Sync for Range<A>
where A: Sync,

§

impl<A> Unpin for Range<A>
where A: Unpin,

§

impl<A> UnwindSafe for Range<A>
where A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T, A> IntoAst<A> for T
where T: Into<A>, A: Ast,

§

fn into_ast(self, _a: &A) -> A

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

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

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.