Interval

Struct Interval 

Source
pub struct Interval<T = isize>
where T: EndPointTrait<T>, isize: Into<T>,
{ /* private fields */ }
Expand description

Canonical implementation of interval. Other implementations of interval is convertible to it.

Both core::ops::Range, core::ops::RangeInclusive are convertable to crate::Interval

Implementations§

Source§

impl<T> Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source

pub fn new(left: Bound<T>, right: Bound<T>) -> Self

Constructor of an interval. Expects closed interval in arguments.

Source

pub fn iter<It>(&self) -> impl Iterator<Item = T>

Convert to interval in canonical format.

Trait Implementations§

Source§

impl<T> Clone for Interval<T>
where T: EndPointTrait<T> + Clone, isize: Into<T>,

Source§

fn clone(&self) -> Interval<T>

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<T> Debug for Interval<T>
where T: EndPointTrait<T> + Debug, isize: Into<T>,

Source§

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

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

impl<T> From<[Bound<T>; 2]> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: [Bound<T>; 2]) -> Self

Converts to this type from the input type.
Source§

impl<T> From<[T; 2]> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: [T; 2]) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(Bound<T>, Bound<T>)> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: (Bound<T>, Bound<T>)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(T, T)> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: (T, T)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Range<T>> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: Range<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<RangeFrom<T>> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: RangeFrom<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<RangeFull> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: RangeFull) -> Self

Converts to this type from the input type.
Source§

impl<T> From<RangeInclusive<T>> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: RangeInclusive<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<RangeTo<T>> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: RangeTo<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<RangeToInclusive<T>> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn from(src: RangeToInclusive<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> IntoIterator for &Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntervalIterator<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> IntoIterator for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntervalIterator<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> NonIterableInterval<T> for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Source§

fn left(&self) -> Bound<T>

The left endpoint of the interval, as is.
Source§

fn right(&self) -> Bound<T>

The right endpoint of the interval, as is.
Source§

fn bounds(&self) -> (Bound<T>, Bound<T>)

Interval in closed format as pair of numbers. To convert open endpoint to closed add or subtract one.
Source§

fn closed_left(&self) -> T

The left endpoint of the interval, converting interval into closed one.
Source§

fn closed_right(&self) -> T

The right endpoint of the interval, converting interval into closed one.
Source§

fn closed_len(&self) -> T

Length of the interval, converting interval into closed one.
Source§

fn closed(&self) -> (T, T)

Interval in closed format as pair of numbers, converting interval into closed one.
Source§

fn canonical(&self) -> Interval<T>

Convert to interval in canonical format.
Source§

impl<T> PartialEq for Interval<T>
where T: EndPointTrait<T> + PartialEq, isize: Into<T>,

Source§

fn eq(&self, other: &Interval<T>) -> 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<T> Copy for Interval<T>
where T: EndPointTrait<T> + Copy, isize: Into<T>,

Source§

impl<T> Eq for Interval<T>
where T: EndPointTrait<T> + Eq, isize: Into<T>,

Source§

impl<T> StructuralPartialEq for Interval<T>
where T: EndPointTrait<T>, isize: Into<T>,

Auto Trait Implementations§

§

impl<T> Freeze for Interval<T>
where isize: Sized, T: Freeze,

§

impl<T> RefUnwindSafe for Interval<T>

§

impl<T> Send for Interval<T>
where isize: Sized, T: Send,

§

impl<T> Sync for Interval<T>
where isize: Sized, T: Sync,

§

impl<T> Unpin for Interval<T>
where isize: Sized, T: Unpin,

§

impl<T> UnwindSafe for Interval<T>
where isize: Sized, T: 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> 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, All> IntoInterval<T> for All
where T: EndPointTrait<T>, isize: Into<T>, Interval<T>: From<All>,

Source§

fn into_interval(self) -> Interval<T>

Convert it into canonical interval.
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.
Source§

impl<T, NonIterableIntervalType> IterableInterval<T> for NonIterableIntervalType
where NonIterableIntervalType: NonIterableInterval<T> + IntoIterator<Item = T>, T: EndPointTrait<T>, isize: Into<T>,