Skip to content

Instantly share code, notes, and snippets.

@lu-zero
Created August 12, 2019 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lu-zero/ec713b9579bdf6a80a648efcf0fdab08 to your computer and use it in GitHub Desktop.
Save lu-zero/ec713b9579bdf6a80a648efcf0fdab08 to your computer and use it in GitHub Desktop.
diff --git a/src/frame/plane.rs b/src/frame/plane.rs
index 71555c42..30f0c020 100644
--- a/src/frame/plane.rs
+++ b/src/frame/plane.rs
@@ -665,6 +665,39 @@ pub mod test {
assert_eq!(&input[..64], &plane.data[..64]);
}
+ #[test]
+ fn mutable_access() {
+ let mut plane = Plane::<u8> {
+ data: PlaneData::from_slice(&vec![
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 2, 3, 4, 0, 0,
+ 0, 0, 8, 7, 6, 5, 0, 0,
+ 0, 0, 9, 8, 7, 6, 0, 0,
+ 0, 0, 2, 3, 4, 5, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ ]),
+ cfg: PlaneConfig {
+ stride: 8,
+ alloc_height: 9,
+ width: 4,
+ height: 4,
+ xdec: 0,
+ ydec: 0,
+ xpad: 0,
+ ypad: 0,
+ xorigin: 2,
+ yorigin: 3,
+ },
+ };
+ let mut s = plane.as_mut_slice();
+
+ s[1][2] = 42;
+
+ }
+
#[test]
fn test_plane_pad() {
let mut plane = Plane::<u8> {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment