IndexRanges

Trait IndexRanges 

Source
pub trait IndexRanges<T: Copy + Ord = usize> {
    type Output;

    // Required method
    fn index_ranges(&self, ranges: &RangeSet<T>) -> Self::Output;
}
Expand description

A trait implemented for collections which can be indexed by a range set.

Required Associated Types§

Source

type Output

The output type of the indexing operation.

Required Methods§

Source

fn index_ranges(&self, ranges: &RangeSet<T>) -> Self::Output

Index the collection by the given range set.

§Panics

Panics if any of the indices in the range set are out of bounds of the collection.

§Examples
use rangeset::{RangeSet, IndexRanges};

let data = [1, 2, 3, 4, 5, 6, 7, 8, 9];
let index = RangeSet::from([(0..3), (5..8)]);

assert_eq!(data.index_ranges(&index), vec![1, 2, 3, 6, 7, 8]);

Implementations on Foreign Types§

Source§

impl IndexRanges for str

Source§

type Output = String

Source§

fn index_ranges(&self, index: &RangeSet<usize>) -> Self::Output

Source§

impl<T: Clone> IndexRanges for [T]

Source§

type Output = Vec<T>

Source§

fn index_ranges(&self, index: &RangeSet<usize>) -> Self::Output

Implementors§