Skip to main content

RangeStart

Trait RangeStart 

Source
pub trait RangeStart<Idx = usize> {
    // Required method
    fn start(&self) -> Idx;
}
Expand description

A range with a defined inclusive lower bound.

This is the shared base of the crate’s extension traits. The implementations for std::ops::RangeTo, std::ops::RangeToInclusive, std::ops::RangeFull, and None anchor the start at Idx::zero(); for a signed index type the negative portion is not represented, so (..-5) reports itself empty.

For std::ops::RangeInclusive, the inherent start method shadows this one; call it as RangeStart::start(&range).

§Examples

use ps_range::RangeStart;

assert_eq!((2..8).start(), 2);
assert_eq!((..8).start(), 0);
assert_eq!(RangeStart::start(&(2..=8)), 2);

Required Methods§

Source

fn start(&self) -> Idx

Returns the inclusive lower bound of the range.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<Idx, T: RangeStart<Idx>> RangeStart<Idx> for &T

Source§

fn start(&self) -> Idx

Source§

impl<Idx, T: RangeStart<Idx>> RangeStart<Idx> for &mut T

Source§

fn start(&self) -> Idx

Source§

impl<Idx, T> RangeStart<Idx> for Option<T>
where Idx: Zero, T: RangeStart<Idx>,

Source§

fn start(&self) -> Idx

Source§

impl<Idx: Clone> RangeStart<Idx> for Range<Idx>

Source§

fn start(&self) -> Idx

Source§

impl<Idx: Clone> RangeStart<Idx> for RangeFrom<Idx>

Source§

fn start(&self) -> Idx

Source§

impl<Idx: Clone> RangeStart<Idx> for RangeInclusive<Idx>

Source§

fn start(&self) -> Idx

Source§

impl<Idx: Zero> RangeStart<Idx> for RangeFull

Source§

fn start(&self) -> Idx

Source§

impl<Idx: Zero> RangeStart<Idx> for RangeTo<Idx>

Source§

fn start(&self) -> Idx

Source§

impl<Idx: Zero> RangeStart<Idx> for RangeToInclusive<Idx>

Source§

fn start(&self) -> Idx

Implementors§

Source§

impl<Idx: Clone + Zero> RangeStart<Idx> for PartialRange<Idx>

Source§

impl<Idx: Clone> RangeStart<Idx> for ps_range::Range<Idx>