From c669b4294e35eff34be2bda3db390a323371ef2f Mon Sep 17 00:00:00 2001 From: Freja Roberts Date: Tue, 20 Feb 2024 14:04:07 +0100 Subject: [PATCH] feat: FetchExt::filtered --- src/fetch/ext.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/fetch/ext.rs b/src/fetch/ext.rs index 6c4728e..6c16a50 100644 --- a/src/fetch/ext.rs +++ b/src/fetch/ext.rs @@ -1,6 +1,6 @@ use crate::{ component::ComponentValue, - filter::{Cmp, Equal, Greater, GreaterEq, Less, LessEq}, + filter::{Cmp, Equal, Filtered, Greater, GreaterEq, Less, LessEq}, relation::RelationExt, Fetch, FetchItem, }; @@ -198,6 +198,15 @@ pub trait FetchExt: Sized { { Map { query: self, func } } + + /// Filter a fetch with another fetch as predicate + fn filtered(self, filter: F) -> Filtered + where + Self: for<'x> FetchItem<'x>, + F: for<'x> Fetch<'x>, + { + Filtered::new(self, filter, true) + } } impl FetchExt for F where F: for<'x> Fetch<'x> {}