diff --git a/crates/cross/src/dim.rs b/crates/cross/src/dim.rs index bb4063d..a354a78 100644 --- a/crates/cross/src/dim.rs +++ b/crates/cross/src/dim.rs @@ -70,7 +70,7 @@ mod test { 3, 4, 5, 0, 10,20, - 10,40,50, + 30,40,50, ]; let s = DimensionedSlice::new(Vec3u::new(3, 2, 2), &data); assert_eq!(s[Vec3u::new(0, 0, 0)], 0); @@ -79,5 +79,27 @@ mod test { assert_eq!(s[Vec3u::new(1, 1, 1)], 40); assert_eq!(s[Vec3u::new(2, 1, 1)], 50); } + + #[test] + fn dimensioned_slice_index_mut() { + let mut data = [ + 0, 1, 2, + 3, 4, 5, + + 0, 10,20, + 30,40,50, + ]; + let mut s = DimensionedSlice::new(Vec3u::new(3, 2, 2), &mut data); + s[Vec3u::new(0, 0, 0)] = 100; + s[Vec3u::new(0, 1, 1)] = 300; + + assert_eq!(data, [ + 100,1, 2, + 3, 4, 5, + + 0, 10, 20, + 300,40,50, + ]); + } }