Skip to main content

OrderedRange

Struct OrderedRange 

Source
pub struct OrderedRange<T: Ord + Clone> {
    pub lo: T,
    pub hi: T,
}
Expand description

A range structure for ordered types.

Represents the interval [lo, hi] in an ordered set, supporting membership tests, containment, and iteration for integer ranges.

Fields§

§lo: T

Lower bound (inclusive).

§hi: T

Upper bound (inclusive).

Implementations§

Source§

impl<T: Ord + Clone> OrderedRange<T>

Source

pub fn new(lo: T, hi: T) -> Self

Create a new range [lo, hi]. Panics if lo > hi.

Source

pub fn contains(&self, x: &T) -> bool

Check if a value is within the range.

Source

pub fn contains_range(&self, other: &OrderedRange<T>) -> bool

Check if another range is fully contained within this range.

Source

pub fn overlaps(&self, other: &OrderedRange<T>) -> bool

Check if two ranges overlap.

Source

pub fn lower(&self) -> &T

Return the lower bound.

Source

pub fn upper(&self) -> &T

Return the upper bound.

Auto Trait Implementations§

§

impl<T> Freeze for OrderedRange<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for OrderedRange<T>
where T: RefUnwindSafe,

§

impl<T> Send for OrderedRange<T>
where T: Send,

§

impl<T> Sync for OrderedRange<T>
where T: Sync,

§

impl<T> Unpin for OrderedRange<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for OrderedRange<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for OrderedRange<T>
where 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, 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.