Skip to content

Commit

Permalink
Merge pull request #286 from dtolnay/array
Browse files Browse the repository at this point in the history
Implement repetition for arrays
  • Loading branch information
dtolnay authored Dec 26, 2024
2 parents aafba72 + 09d1e42 commit d978c51
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ pub mod ext {
}
}

impl<'q, T: 'q, const N: usize> RepAsIteratorExt<'q> for [T; N] {
type Iter = slice::Iter<'q, T>;

fn quote_into_iter(&'q self) -> (Self::Iter, HasIter) {
(self.iter(), HasIter)
}
}

impl<'q, T: 'q> RepAsIteratorExt<'q> for Vec<T> {
type Iter = slice::Iter<'q, T>;

Expand Down
3 changes: 3 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ fn test_array() {

let ref_slice: &[X] = &[X, X];
let _ = quote!(#(#ref_slice #ref_slice)*);

let array_of_array: [[u8; 2]; 2] = [[0; 2]; 2];
let _ = quote!(#(#(#array_of_array)*)*);
}

#[test]
Expand Down

0 comments on commit d978c51

Please sign in to comment.