Removes the number of rows from `v` required to emit the right number of rows, returning a `Vec` with elements taken, and the remaining values in `v`. This avoids copying if Self::All
(&self, v: &mut Vec<T>)
| 40 | /// |
| 41 | /// This avoids copying if Self::All |
| 42 | pub fn take_needed<T>(&self, v: &mut Vec<T>) -> Vec<T> { |
| 43 | match self { |
| 44 | Self::All => { |
| 45 | // Take the entire vector, leave new (empty) vector |
| 46 | std::mem::take(v) |
| 47 | } |
| 48 | Self::First(n) => { |
| 49 | // get end n+1,.. values into t |
| 50 | let mut t = v.split_off(*n); |
| 51 | // leave n+1,.. in v |
| 52 | std::mem::swap(v, &mut t); |
| 53 | t |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /// `GroupsAccumulator` implements a single aggregate (e.g. AVG) and |
no test coverage detected