cross: DimSlice: add dim/offset accessors
This commit is contained in:
@@ -17,12 +17,12 @@ impl<T> DimSlice<T> {
|
|||||||
pub fn new(dim: Vec3u, items: T) -> Self {
|
pub fn new(dim: Vec3u, items: T) -> Self {
|
||||||
Self { dim, items }
|
Self { dim, items }
|
||||||
}
|
}
|
||||||
pub fn indices(&self) -> DimIter {
|
|
||||||
DimIter::new(self.dim)
|
|
||||||
}
|
|
||||||
pub fn dim(&self) -> Vec3u {
|
pub fn dim(&self) -> Vec3u {
|
||||||
self.dim
|
self.dim
|
||||||
}
|
}
|
||||||
|
pub fn indices(&self) -> DimIter {
|
||||||
|
DimIter::new(self.dim)
|
||||||
|
}
|
||||||
|
|
||||||
/// re-borrow the slice with a different lifetime.
|
/// re-borrow the slice with a different lifetime.
|
||||||
pub fn as_ref<R: ?Sized>(&self) -> DimSlice<&R>
|
pub fn as_ref<R: ?Sized>(&self) -> DimSlice<&R>
|
||||||
|
@@ -17,6 +17,12 @@ impl<T> OffsetDimSlice<T> {
|
|||||||
pub fn new(offset: Vec3u, dim: Vec3u, items: T) -> Self {
|
pub fn new(offset: Vec3u, dim: Vec3u, items: T) -> Self {
|
||||||
Self { offset, inner: DimSlice::new(dim, items) }
|
Self { offset, inner: DimSlice::new(dim, items) }
|
||||||
}
|
}
|
||||||
|
pub fn dim(&self) -> Vec3u {
|
||||||
|
self.inner.dim()
|
||||||
|
}
|
||||||
|
pub fn offset(&self) -> Vec3u {
|
||||||
|
self.offset
|
||||||
|
}
|
||||||
pub fn indices(&self) -> OffsetDimIter {
|
pub fn indices(&self) -> OffsetDimIter {
|
||||||
OffsetDimIter::new(self.offset, self.inner.indices())
|
OffsetDimIter::new(self.offset, self.inner.indices())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user