cross: DimSlice: add dim/offset accessors

This commit is contained in:
2022-08-18 04:32:43 -07:00
parent fb9d982545
commit e72c0ec11d
2 changed files with 9 additions and 3 deletions

View File

@@ -17,12 +17,12 @@ impl<T> DimSlice<T> {
pub fn new(dim: Vec3u, items: T) -> Self {
Self { dim, items }
}
pub fn indices(&self) -> DimIter {
DimIter::new(self.dim)
}
pub fn dim(&self) -> Vec3u {
self.dim
}
pub fn indices(&self) -> DimIter {
DimIter::new(self.dim)
}
/// re-borrow the slice with a different lifetime.
pub fn as_ref<R: ?Sized>(&self) -> DimSlice<&R>

View File

@@ -17,6 +17,12 @@ impl<T> OffsetDimSlice<T> {
pub fn new(offset: Vec3u, dim: Vec3u, items: T) -> Self {
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 {
OffsetDimIter::new(self.offset, self.inner.indices())
}