Implemented `SliceRange` for `RangeInclusive` (#911)
This commit is contained in:
parent
2287e5088a
commit
885bbdaf97
|
@ -1,5 +1,5 @@
|
|||
use std::marker::PhantomData;
|
||||
use std::ops::{Range, RangeFrom, RangeFull, RangeTo};
|
||||
use std::ops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeTo};
|
||||
use std::slice;
|
||||
|
||||
use crate::base::allocator::Allocator;
|
||||
|
@ -806,6 +806,25 @@ impl<D: Dim> SliceRange<D> for RangeFull {
|
|||
}
|
||||
}
|
||||
|
||||
impl<D: Dim> SliceRange<D> for RangeInclusive<usize> {
|
||||
type Size = Dynamic;
|
||||
|
||||
#[inline(always)]
|
||||
fn begin(&self, _: D) -> usize {
|
||||
*self.start()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn end(&self, _: D) -> usize {
|
||||
*self.end() + 1
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn size(&self, _: D) -> Self::Size {
|
||||
Dynamic::new(*self.end() + 1 - *self.start())
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: see how much of this overlaps with the general indexing
|
||||
// methods from indexing.rs.
|
||||
impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||
|
|
Loading…
Reference in New Issue