1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::FixedVec;
use alloc::vec::Vec;

impl<T> FromIterator<T> for FixedVec<T> {
    fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
        let vec: Vec<_> = iter.into_iter().collect();
        vec.into()
    }
}

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

    #[test]
    fn from_iter() {
        let fixed: FixedVec<_> = (0..20).collect();
        assert_eq!((0..20).collect::<Vec<_>>().as_slice(), fixed.as_slice());
        assert_eq!(fixed.len(), 20);
        assert!(fixed.capacity() >= 20);
    }
}