Skip to content

Commit 15bbfac

Browse files
committed
Add a test for slice::as_chunks_mut usage
1 parent 2585624 commit 15bbfac

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![cfg_attr(feature = "unstable", feature(const_generics))]
1111
#![cfg_attr(feature = "unstable", feature(slice_range))]
1212
#![cfg_attr(feature = "unstable", allow(incomplete_features))]
13+
#![cfg_attr(all(feature = "unstable", test), feature(slice_as_chunks))]
1314
#![warn(missing_docs)]
1415

1516
use access::{ReadOnly, ReadWrite, Readable, Writable, WriteOnly};
@@ -869,4 +870,15 @@ mod tests {
869870
assert_eq!(volatile.map(|s| &s.field_1).read(), 61);
870871
assert_eq!(volatile.map(|s| &s.field_2).read(), false);
871872
}
873+
874+
#[cfg(feature = "unstable")]
875+
#[test]
876+
fn test_chunks() {
877+
let mut val = [1, 2, 3, 4, 5, 6];
878+
let mut volatile = Volatile::new(&mut val[..]);
879+
let mut chunks = volatile.map_mut(|s| s.as_chunks_mut().0);
880+
chunks.index_mut(1).write([10, 11, 12]);
881+
assert_eq!(chunks.index(0).read(), [1, 2, 3]);
882+
assert_eq!(chunks.index(1).read(), [10, 11, 12]);
883+
}
872884
}

0 commit comments

Comments
 (0)