Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-utils/src/concat_vec.rs
7884 views
1
pub 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
6
impl<T> private::Sealed for Vec<Vec<T>> {}
7
8
impl<T> ConcatVec<T> for Vec<Vec<T>>
9
where
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
21
mod private {
22
pub trait Sealed {}
23
}
24
25