Iterator: Test that Iterator can be used in a for loop

`for x in foo` depends on foo implementing IntoIterator.
This commit is contained in:
Jan Alexander Steffens (heftig) 2019-09-05 11:01:16 +02:00 committed by Sebastian Dröge
parent dcec895b30
commit 23fe9efe08

View file

@ -761,6 +761,15 @@ mod tests {
assert_eq!(it.next(), None);
}
#[test]
fn test_into_iter() {
let mut v = vec![1i32, 2, 3].into_iter();
for x in Iterator::from_vec(vec![1i32, 2, 3]) {
assert_eq!(x.unwrap(), v.next().unwrap());
}
assert_eq!(v.next(), None);
}
#[test]
fn test_std_resync_collect() {
use prelude::*;