We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eb594a2 commit 255f285Copy full SHA for 255f285
src/libcore/slice/mod.rs
@@ -859,7 +859,6 @@ impl<T> [T] {
859
/// ```
860
///
861
/// [`chunks`]: #method.chunks
862
- /// [`rchunks_exact`]: #method.rchunks_exact
863
#[unstable(feature = "array_chunks", issue = "none")]
864
#[inline]
865
pub fn array_chunks<const N: usize>(&self) -> ArrayChunks<'_, T, N> {
src/libcore/tests/lib.rs
@@ -1,4 +1,5 @@
1
#![feature(alloc_layout_extra)]
2
+#![feature(array_chunks)]
3
#![feature(bool_to_option)]
4
#![feature(bound_cloned)]
5
#![feature(box_syntax)]
src/libcore/tests/slice.rs
@@ -433,6 +433,28 @@ fn test_chunks_exact_mut_zip() {
433
assert_eq!(v1, [13, 14, 19, 20, 4]);
434
}
435
436
+// FIXME(#71154)
437
+// FIXME(const_generics)
438
+// We can't yet use `v.array_chunks::<3>()`, so until either #71154 or a
439
+// different PR implementing const arguments in type dependent paths lands,
440
+// we can't yet test many uses.
441
+#[test]
442
+fn test_array_chunks_simple() {
443
+ let v: &[i32] = &[0, 1, 2, 3, 4, 5];
444
+ let mut c = <[i32]>::array_chunks(&v);
445
+ assert!(matches!(c.next(), Some(&[0, 1, 2])));
446
+ assert!(matches!(c.next(), Some(&[3, 4, 5])));
447
+ assert!(matches!(c.next(), None));
448
+
449
+ let v2: &[i32] = &[0, 1, 2, 3, 4];
450
+ let c2 = <[i32]>::array_chunks(&v2);
451
+ for &[a, b, c] in c2 {
452
+ assert_eq!(a, 0i32);
453
+ assert_eq!(b, 1i32);
454
+ assert_eq!(c, 2i32);
455
+ }
456
+}
457
458
#[test]
459
fn test_rchunks_count() {
460
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
0 commit comments