polars_utils/
concat_vec.rs

1pub trait ConcatVec<T>: private::Sealed {
2    /// `concat()` for `Vec<Vec<T>>` that avoids clones if `self` is length-1.
3    fn concat_vec(self) -> Vec<T>;
4}
5
6impl<T> private::Sealed for Vec<Vec<T>> {}
7
8impl<T> ConcatVec<T> for Vec<Vec<T>>
9where
10    T: Copy,
11{
12    fn concat_vec(mut self) -> Vec<T> {
13        if self.len() == 1 {
14            self.pop().unwrap()
15        } else {
16            self.concat()
17        }
18    }
19}
20
21mod private {
22    pub trait Sealed {}
23}