Skip to content

Commit 2da179a

Browse files
committed
Add find_all method to Store
Resolves #1633. Signed-off-by: Alexander Gil <[email protected]>
1 parent 4f1e889 commit 2da179a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

kube-runtime/src/reflector/store.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,21 @@ where
257257
.cloned()
258258
}
259259

260+
/// Retrieve all `clone()` of the entries found by the given predicate
261+
#[must_use]
262+
pub fn find_all<P>(&self, predicate: P) -> Vec<Arc<K>>
263+
where
264+
P: Fn(&K) -> bool,
265+
{
266+
self.store
267+
.read()
268+
.iter()
269+
.map(|(_, k)| k)
270+
.filter(|k| predicate(k.as_ref()))
271+
.cloned()
272+
.collect()
273+
}
274+
260275
/// Return the number of elements in the store
261276
#[must_use]
262277
pub fn len(&self) -> usize {

0 commit comments

Comments
 (0)