mirror of
https://gitee.com/openharmony/third_party_rust_quote
synced 2024-11-23 07:10:01 +00:00
Merge pull request #181 from dtolnay/array
Delete fixed sized array repetition impls
This commit is contained in:
commit
7d5d36017b
@ -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;
|
||||
|
||||
|
@ -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> );
|
||||
|
Loading…
Reference in New Issue
Block a user