orx_concurrent_vec/concurrent_slice/
to_vec.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use super::ConcurrentSlice;
use crate::elem::ConcurrentElement;
use alloc::vec::Vec;
use orx_fixed_vec::IntoConcurrentPinnedVec;

impl<'a, T, P> ConcurrentSlice<'a, T, P>
where
    P: IntoConcurrentPinnedVec<ConcurrentElement<T>>,
{
    /// Clones the values of elements of the slice into a regular vector.
    pub fn clone_to_vec(&self) -> Vec<T>
    where
        T: Clone,
    {
        let iter = self.iter_cloned();
        let mut vec = Vec::with_capacity(self.len());
        for x in iter {
            vec.push(x);
        }
        vec
    }
}