Skip to content

Commit

Permalink
feat: FetchExt::filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Feb 20, 2024
1 parent d17d513 commit c669b42
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/fetch/ext.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down Expand Up @@ -198,6 +198,15 @@ pub trait FetchExt: Sized {
{
Map { query: self, func }
}

/// Filter a fetch with another fetch as predicate
fn filtered<F>(self, filter: F) -> Filtered<Self, F>
where
Self: for<'x> FetchItem<'x>,
F: for<'x> Fetch<'x>,
{
Filtered::new(self, filter, true)
}
}

impl<F> FetchExt for F where F: for<'x> Fetch<'x> {}

0 comments on commit c669b42

Please sign in to comment.