@@ -27,7 +27,7 @@ pub use typenum;
27
27
pub use typenum:: consts;
28
28
29
29
use core:: {
30
- array:: { IntoIter , TryFromSliceError } ,
30
+ array:: TryFromSliceError ,
31
31
borrow:: { Borrow , BorrowMut } ,
32
32
cmp:: Ordering ,
33
33
fmt:: { self , Debug } ,
@@ -307,6 +307,21 @@ where
307
307
}
308
308
}
309
309
310
+ impl < T , U > IntoIterator for Array < T , U >
311
+ where
312
+ U : ArraySize ,
313
+ {
314
+ type Item = T ;
315
+ type IntoIter = <U :: ArrayType < T > as IntoIterator >:: IntoIter ;
316
+
317
+ /// Creates a consuming iterator, that is, one that moves each value out of
318
+ /// the array (from start to end). The array cannot be used after calling
319
+ /// this unless `T` implements `Copy`, so the whole array is copied.
320
+ fn into_iter ( self ) -> Self :: IntoIter {
321
+ self . 0 . into_iter ( )
322
+ }
323
+ }
324
+
310
325
impl < T , U > PartialEq for Array < T , U >
311
326
where
312
327
T : PartialEq ,
@@ -495,9 +510,9 @@ impl<T, const N: usize> ArrayExt<T> for [T; N] {
495
510
///
496
511
/// NOTE: do not implement this trait yourself. It is implemented for types in
497
512
/// [`typenum::consts`].
498
- pub unsafe trait ArraySize : Unsigned {
513
+ pub unsafe trait ArraySize : Unsigned + ' static {
499
514
/// Array type which corresponds to this size.
500
- type ArrayType < T > : ArrayExt < T > + AsRef < [ T ] > + AsMut < [ T ] > + IntoArray < T > ;
515
+ type ArrayType < T > : ArrayExt < T > + AsRef < [ T ] > + AsMut < [ T ] > + IntoArray < T > + IntoIterator < Item = T > ;
501
516
}
502
517
503
518
/// Convert the given type into an [`Array`].
@@ -570,18 +585,6 @@ macro_rules! impl_array_size {
570
585
}
571
586
}
572
587
573
- impl <T > IntoIterator for Array <T , typenum:: $ty> {
574
- type Item = T ;
575
- type IntoIter = IntoIter <T , $len>;
576
-
577
- /// Creates a consuming iterator, that is, one that moves each value out of
578
- /// the array (from start to end). The array cannot be used after calling
579
- /// this unless `T` implements `Copy`, so the whole array is copied.
580
- fn into_iter( self ) -> Self :: IntoIter {
581
- self . 0 . into_iter( )
582
- }
583
- }
584
-
585
588
impl <' a, T > IntoIterator for & ' a Array <T , typenum:: $ty> {
586
589
type Item = & ' a T ;
587
590
type IntoIter = Iter <' a, T >;
0 commit comments