MCPcopy Create free account
hub / github.com/PRQL/prql / pluck

Method pluck

prqlc/prqlc/src/utils/mod.rs:42–58  ·  view source on GitHub ↗
(&mut self, f: F)

Source from the content-addressed store, hash-verified

40
41impl<T> Pluck<T> for Vec<T> {
42 fn pluck<R, F>(&mut self, f: F) -> Vec<R>
43 where
44 F: Fn(T) -> Result<R, T>,
45 {
46 let mut matched = Vec::new();
47 let mut not_matched = Vec::new();
48
49 for transform in self.drain(..) {
50 match f(transform) {
51 Ok(t) => matched.push(t),
52 Err(transform) => not_matched.push(transform),
53 }
54 }
55
56 self.extend(not_matched);
57 matched
58 }
59}
60
61/// Breaks up a [Vec] into two parts at the position of first matching element.

Callers 2

pluck_annotationFunction · 0.80

Calls 2

pushMethod · 0.80
fFunction · 0.50

Tested by

no test coverage detected