impl IntoIterator for &/&mut ArrayVec (#69)

These just create slice iterators, but the impls are useful to have for
contexts that don't auto-deref, as in the new tests.
This commit is contained in:
Josh Stone
2020-03-31 12:36:39 -07:00
committed by GitHub
parent 0c31798eba
commit d04abff44c
3 changed files with 31 additions and 3 deletions
+9 -1
View File
@@ -99,8 +99,16 @@ fn ArrayVec_iteration() {
let av = array_vec!([i32; 4], 10, 11, 12, 13);
let av2: ArrayVec<[i32; 4]> = av.clone().into_iter().collect();
let mut av2: ArrayVec<[i32; 4]> = av.clone().into_iter().collect();
assert_eq!(av, av2);
// IntoIterator for &mut ArrayVec
for x in &mut av2 {
*x = -*x;
}
// IntoIterator for &ArrayVec
assert!(av.iter().zip(&av2).all(|(&a, &b)| a == -b));
}
#[test]