Skip to content

Commit d978c51

Browse files
authored
Merge pull request #286 from dtolnay/array
Implement repetition for arrays
2 parents aafba72 + 09d1e42 commit d978c51

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/runtime.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ pub mod ext {
126126
}
127127
}
128128

129+
impl<'q, T: 'q, const N: usize> RepAsIteratorExt<'q> for [T; N] {
130+
type Iter = slice::Iter<'q, T>;
131+
132+
fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
133+
(self.iter(), HasIter)
134+
}
135+
}
136+
129137
impl<'q, T: 'q> RepAsIteratorExt<'q> for Vec<T> {
130138
type Iter = slice::Iter<'q, T>;
131139

tests/test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ fn test_array() {
105105

106106
let ref_slice: &[X] = &[X, X];
107107
let _ = quote!(#(#ref_slice #ref_slice)*);
108+
109+
let array_of_array: [[u8; 2]; 2] = [[0; 2]; 2];
110+
let _ = quote!(#(#(#array_of_array)*)*);
108111
}
109112

110113
#[test]

0 commit comments

Comments
 (0)