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
use crate::FixedVec;
use alloc::vec::IntoIter;

impl<T> IntoIterator for FixedVec<T> {
    type Item = T;
    type IntoIter = IntoIter<T>;

    fn into_iter(self) -> Self::IntoIter {
        self.data.into_iter()
    }
}

#[cfg(test)]
mod tests {
    use crate::prelude::*;
    use alloc::vec::Vec;

    #[test]
    fn into_iter() {
        let mut vec = FixedVec::new(4);
        for i in 0..vec.capacity() {
            vec.push(i);
        }

        let vec_from_iter: Vec<_> = vec.into_iter().map(|x| x + 1).collect();
        assert_eq!(vec_from_iter, &[1, 2, 3, 4]);
    }
}