Skip to main content

RangeExt

Trait RangeExt 

Source
pub trait RangeExt<T> {
    // Required methods
    fn in_range(&self, outer: &Range<T>) -> bool;
    fn intersects(&self, other: &Range<T>) -> bool;
    fn intersect(&self, other: &Range<T>) -> Option<Range<T>>;
    fn trim(&self, trim_to_len: T) -> Option<Range<T>>;
}
Expand description

Extension trait providing range-checking methods directly on Range<T>.

Required Methods§

Source

fn in_range(&self, outer: &Range<T>) -> bool

Returns true if this range is fully contained inside outer.

Source

fn intersects(&self, other: &Range<T>) -> bool

Returns true if this range overlaps with other.

Source

fn intersect(&self, other: &Range<T>) -> Option<Range<T>>

Computes the intersection of this range with other.

Source

fn trim(&self, trim_to_len: T) -> Option<Range<T>>

Trims this range to fit within 0..trim_to_len.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Ord + Copy> RangeExt<T> for Range<T>

Source§

fn in_range(&self, outer: &Range<T>) -> bool

Source§

fn intersects(&self, other: &Range<T>) -> bool

Source§

fn intersect(&self, other: &Range<T>) -> Option<Range<T>>

Source§

fn trim(&self, trim_to_len: T) -> Option<Range<T>>

Implementors§