pub struct LazyQuery<'a, T: 'static, I>{ /* private fields */ }Expand description
A lazy query builder that uses iterators for deferred execution.
Unlike the standard Query, LazyQuery doesn’t execute until you call
a terminal operation like .collect(), .count(), or .first().
§Benefits
- Deferred execution: No work until results needed
- Iterator fusion: Rust optimizes chained operations
- Early termination:
.take()stops as soon as enough items found - Composable: Build complex queries by composition
§Example
ⓘ
// Nothing executes yet
let query = LazyQuery::new(&products)
.where_(Product::price_r(), |&p| p < 100.0)
.where_(Product::stock_r(), |&s| s > 0);
// Execution happens here
let results: Vec<_> = query.collect();Implementations§
Source§impl<'a, T: 'static, I> LazyQuery<'a, T, I>
impl<'a, T: 'static, I> LazyQuery<'a, T, I>
Sourcepub fn where_<F, P>(
self,
path: KeyPaths<T, F>,
predicate: P,
) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>
pub fn where_<F, P>( self, path: KeyPaths<T, F>, predicate: P, ) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>
Sourcepub fn select_lazy<F>(
self,
path: KeyPaths<T, F>,
) -> impl Iterator<Item = F> + 'awhere
F: Clone + 'static,
I: 'a,
pub fn select_lazy<F>(
self,
path: KeyPaths<T, F>,
) -> impl Iterator<Item = F> + 'awhere
F: Clone + 'static,
I: 'a,
Sourcepub fn take_lazy(
self,
n: usize,
) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>where
I: 'a,
pub fn take_lazy(
self,
n: usize,
) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>where
I: 'a,
Sourcepub fn skip_lazy(
self,
n: usize,
) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>where
I: 'a,
pub fn skip_lazy(
self,
n: usize,
) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>where
I: 'a,
Source§impl<'a, T: 'static, I> LazyQuery<'a, T, I>
impl<'a, T: 'static, I> LazyQuery<'a, T, I>
Sourcepub fn min_by_float(self, path: KeyPaths<T, f64>) -> Option<f64>where
I: 'a,
pub fn min_by_float(self, path: KeyPaths<T, f64>) -> Option<f64>where
I: 'a,
Finds minimum float value (terminal operation).
Sourcepub fn max_by_float(self, path: KeyPaths<T, f64>) -> Option<f64>where
I: 'a,
pub fn max_by_float(self, path: KeyPaths<T, f64>) -> Option<f64>where
I: 'a,
Finds maximum float value (terminal operation).
Sourcepub fn where_after_systemtime(
self,
path: KeyPaths<T, SystemTime>,
reference: SystemTime,
) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>
pub fn where_after_systemtime( self, path: KeyPaths<T, SystemTime>, reference: SystemTime, ) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>
Sourcepub fn where_before_systemtime(
self,
path: KeyPaths<T, SystemTime>,
reference: SystemTime,
) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>
pub fn where_before_systemtime( self, path: KeyPaths<T, SystemTime>, reference: SystemTime, ) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>
Sourcepub fn where_between_systemtime(
self,
path: KeyPaths<T, SystemTime>,
start: SystemTime,
end: SystemTime,
) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>
pub fn where_between_systemtime( self, path: KeyPaths<T, SystemTime>, start: SystemTime, end: SystemTime, ) -> LazyQuery<'a, T, impl Iterator<Item = &'a T> + 'a>
Trait Implementations§
Source§impl<'a, T: 'static, I> IntoIterator for LazyQuery<'a, T, I>
impl<'a, T: 'static, I> IntoIterator for LazyQuery<'a, T, I>
Auto Trait Implementations§
impl<'a, T, I> Freeze for LazyQuery<'a, T, I>where
I: Freeze,
impl<'a, T, I> RefUnwindSafe for LazyQuery<'a, T, I>where
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, I> Send for LazyQuery<'a, T, I>
impl<'a, T, I> Sync for LazyQuery<'a, T, I>
impl<'a, T, I> Unpin for LazyQuery<'a, T, I>where
I: Unpin,
impl<'a, T, I> UnwindSafe for LazyQuery<'a, T, I>where
I: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more