copy_stack_vec/iter/array/from_iterator.rs
1// This file is part of copy-stack-vec.
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4// Crate imports
5use crate::vec::CopyStackVec;
6
7impl<T: Copy + Default, const N: usize> FromIterator<T> for CopyStackVec<T, N> {
8 /// Collecting into CopyStackVec<T, N> takes at most the first N elements from the iterator and
9 /// does not consume any further elements.
10 fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
11 let mut v = Self::default();
12 v.extend(iter);
13 v
14 }
15}