Struct interval_adapter::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 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<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>,

§

type Item = T

The type of the elements being iterated over.
§

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

§

type Item = T

The type of the elements being iterated over.
§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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> 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> ToOwned for T
where T: Clone,

§

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

§

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

§

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