Merge pull request #181 from dtolnay/array

Delete fixed sized array repetition impls
This commit is contained in:
David Tolnay 2021-04-02 00:32:01 -04:00 committed by GitHub
commit 7d5d36017b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 19 deletions

View File

@ -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;

View File

@ -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> );