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§
Required Methods§
Sourcefn index_ranges(&self, ranges: &RangeSet<T>) -> Self::Output
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]);