Enum ContinuousRange

Source
pub enum ContinuousRange<Idx> {
    Empty,
    Single(Idx),
    Inclusive(Idx, Idx),
    Exclusive(Idx, Idx),
    StartExclusive(Idx, Idx),
    EndExclusive(Idx, Idx),
    From(Idx),
    FromExclusive(Idx),
    To(Idx),
    ToExclusive(Idx),
    Full,
}

Variants§

§

Empty

A range containing no value

[]

§

Single(Idx)

A range containing a single value

value

§

Inclusive(Idx, Idx)

A range between start (inclusive) and end (inclusive)

[start..end]

§

Exclusive(Idx, Idx)

A range between start (exclusive) and end (exclusive)

(start..end)

§

StartExclusive(Idx, Idx)

A range between start (exclusive) and end (inclusive)

(start..end]

§

EndExclusive(Idx, Idx)

A range between start (inclusive) and end (exclusive)

[start..end)

§

From(Idx)

A range starting from start (inclusive)

[start..)

§

FromExclusive(Idx)

A range starting from start (exclusive)

(start..)

§

To(Idx)

A range ending with end (inclusive)

(..end]

§

ToExclusive(Idx)

A range ending with end (exclusive)

(..end)

§

Full

A range containing all values

Implementations§

Source§

impl<Idx: PartialOrd + Clone> ContinuousRange<Idx>

Source

pub fn empty() -> ContinuousRange<Idx>

A range containing no value

[]

Source

pub fn single(value: Idx) -> ContinuousRange<Idx>

A range containing a single value

value

Source

pub fn inclusive(start: Idx, end: Idx) -> ContinuousRange<Idx>
where Idx: PartialOrd,

A range between start (inclusive) and end (inclusive)

[start..end]

Source

pub fn exclusive(start: Idx, end: Idx) -> ContinuousRange<Idx>
where Idx: PartialOrd,

A range between start (exclusive) and end (exclusive)

(start..end)

Source

pub fn start_exclusive(start: Idx, end: Idx) -> ContinuousRange<Idx>
where Idx: PartialOrd,

A range between start (exclusive) and end (inclusive)

(start..end]

Source

pub fn end_exclusive(start: Idx, end: Idx) -> ContinuousRange<Idx>
where Idx: PartialOrd,

A range between start (inclusive) and end (exclusive)

[start..end)

Source

pub fn from(start: Idx) -> ContinuousRange<Idx>

A range starting from start (inclusive)

[start..)

Source

pub fn from_exclusive(start: Idx) -> ContinuousRange<Idx>

A range starting from start (exclusive)

(start..)

Source

pub fn to(end: Idx) -> ContinuousRange<Idx>

A range ending with end (inclusive)

(..end]

Source

pub fn to_exclusive(end: Idx) -> ContinuousRange<Idx>

A range ending with end (exclusive)

(..end)

Source

pub fn full() -> ContinuousRange<Idx>

A range containing all values

Source

pub fn from_bounds(bounds: (Bound<&Idx>, Bound<&Idx>)) -> Self

Create a new range from the specified bounds

Source

pub fn range_bounds(&self) -> Option<(Bound<&Idx>, Bound<&Idx>)>

Get the bounds of the range or None if empty

Source

pub fn start(&self) -> Option<Bound<&Idx>>

Source

pub fn end(&self) -> Option<Bound<&Idx>>

Source

pub fn contains(&self, value: impl Borrow<Idx>) -> bool
where Idx: PartialOrd + PartialEq,

Check if the range contains the provide value

Source

pub fn contains_range(&self, other: &ContinuousRange<Idx>) -> bool
where Idx: Debug,

Source

pub fn disjoint_from_range(&self, other: &ContinuousRange<Idx>) -> bool
where Idx: Debug,

Source

pub fn union( &self, other: &ContinuousRange<Idx>, ) -> Option<ContinuousRange<Idx>>
where Idx: PartialOrd + Debug,

Source

pub fn intersection(&self, other: &ContinuousRange<Idx>) -> ContinuousRange<Idx>
where Idx: PartialOrd + Debug,

Source

pub fn difference( &self, other: &ContinuousRange<Idx>, ) -> Option<ContinuousRange<Idx>>
where Idx: PartialOrd + Debug,

Source

pub fn intersects(&self, other: &ContinuousRange<Idx>) -> bool
where Idx: Debug,

Source

pub fn compare(&self, other: &ContinuousRange<Idx>) -> Option<RangesRelation>
where Idx: Debug,

Compare the bounds of two ranges. Returns Option::None if an empty range is compared to a non-empty range.

§Panics

This function may panic if the PartialOrd contract isn’t respected.

Source

pub fn simplify_mut(&mut self)
where Idx: PartialOrd,

Source

pub fn simplify(&self) -> Self
where Idx: PartialOrd,

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_full(&self) -> bool

Trait Implementations§

Source§

impl<Idx: Clone> Clone for ContinuousRange<Idx>

Source§

fn clone(&self) -> ContinuousRange<Idx>

Returns a copy 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<Idx: Debug> Debug for ContinuousRange<Idx>

Source§

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

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

impl<Idx> Default for ContinuousRange<Idx>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Idx: PartialOrd + Clone> From<()> for ContinuousRange<Idx>

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl<Idx> From<ContinuousRange<Idx>> for Range<Idx>

Source§

fn from(r: ContinuousRange<Idx>) -> Self

Converts to this type from the input type.
Source§

impl<Idx: PartialOrd + Clone> From<Range<Idx>> for ContinuousRange<Idx>

Source§

fn from(r: Range<Idx>) -> Self

Converts to this type from the input type.
Source§

impl<Idx: PartialOrd + Clone> From<RangeFrom<Idx>> for ContinuousRange<Idx>

Source§

fn from(r: RangeFrom<Idx>) -> Self

Converts to this type from the input type.
Source§

impl<Idx: PartialOrd + Clone> From<RangeFull> for ContinuousRange<Idx>

Source§

fn from(_: RangeFull) -> Self

Converts to this type from the input type.
Source§

impl<Idx: PartialOrd + Clone> From<RangeInclusive<Idx>> for ContinuousRange<Idx>

Source§

fn from(r: RangeInclusive<Idx>) -> Self

Converts to this type from the input type.
Source§

impl<Idx: PartialOrd + Clone> From<RangeTo<Idx>> for ContinuousRange<Idx>

Source§

fn from(r: RangeTo<Idx>) -> Self

Converts to this type from the input type.
Source§

impl<Idx: PartialOrd + Clone> From<RangeToInclusive<Idx>> for ContinuousRange<Idx>

Source§

fn from(r: RangeToInclusive<Idx>) -> Self

Converts to this type from the input type.
Source§

impl<Idx: Hash> Hash for ContinuousRange<Idx>

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<Idx: PartialEq> PartialEq for ContinuousRange<Idx>

Source§

fn eq(&self, other: &ContinuousRange<Idx>) -> 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<Idx> StructuralPartialEq for ContinuousRange<Idx>

Auto Trait Implementations§

§

impl<Idx> Freeze for ContinuousRange<Idx>
where Idx: Freeze,

§

impl<Idx> RefUnwindSafe for ContinuousRange<Idx>
where Idx: RefUnwindSafe,

§

impl<Idx> Send for ContinuousRange<Idx>
where Idx: Send,

§

impl<Idx> Sync for ContinuousRange<Idx>
where Idx: Sync,

§

impl<Idx> Unpin for ContinuousRange<Idx>
where Idx: Unpin,

§

impl<Idx> UnwindSafe for ContinuousRange<Idx>
where Idx: 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, dst: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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, 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.