polars_utils/
scratch_vec.rs1use crate::UnitVec;
2
3#[derive(Default)]
5pub struct ScratchVec<T>(Vec<T>);
6
7impl<T> ScratchVec<T> {
8 pub fn with_capacity(capacity: usize) -> Self {
9 Self(Vec::with_capacity(capacity))
10 }
11
12 pub fn get(&mut self) -> &mut Vec<T> {
14 self.0.clear();
15 &mut self.0
16 }
17}
18
19#[derive(Default)]
21pub struct ScratchUnitVec<T>(UnitVec<T>);
22
23impl<T> ScratchUnitVec<T> {
24 pub fn with_capacity(capacity: usize) -> Self {
25 Self(UnitVec::with_capacity(capacity))
26 }
27
28 pub fn get(&mut self) -> &mut UnitVec<T> {
30 self.0.clear();
31 &mut self.0
32 }
33}