Skip to content

Commit

Permalink
Merge pull request #181 from dtolnay/array
Browse files Browse the repository at this point in the history
Delete fixed sized array repetition impls
  • Loading branch information
dtolnay authored Apr 2, 2021
2 parents b4b1087 + 58bc466 commit 7d5d360
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,6 @@ pub mod ext {
}
}

macro_rules! array_rep_slice {
($($l:tt)*) => {
$(
impl<'q, T: 'q> RepAsIteratorExt<'q> for [T; $l] {
type Iter = slice::Iter<'q, T>;

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

array_rep_slice!(
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
);

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

Expand Down
21 changes: 21 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ fn test_iter() {
assert_eq!("X , X , X , X", quote!(#(#primes),*).to_string());
}

#[test]
fn test_array() {
let array: [u8; 40] = [0; 40];
let _ = quote!(#(#array #array)*);

let ref_array: &[u8; 40] = &[0; 40];
let _ = quote!(#(#ref_array #ref_array)*);

let ref_slice: &[u8] = &[0; 40];
let _ = quote!(#(#ref_slice #ref_slice)*);

let array: [X; 2] = [X, X]; // !Copy
let _ = quote!(#(#array #array)*);

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

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

#[test]
fn test_advanced() {
let generics = quote!( <'a, T> );
Expand Down

0 comments on commit 7d5d360

Please sign in to comment.