pub struct TryQueryBuilder<T, E> { /* private fields */ }Expand description
A lazy pipeline of fallible items produced by try_select or try_where_.
Each element in the pipeline is either Ok(value) or Err(error).
Two terminal operations determine how errors are handled:
collect_partitioned: keep going, split results into(ok_vec, err_vec)collect_results: stop at the firstErr, returningErr(e)
Implementations§
Source§impl<T, E> TryQueryBuilder<T, E>
impl<T, E> TryQueryBuilder<T, E>
Sourcepub fn collect_partitioned(self) -> (Vec<T>, Vec<E>)
pub fn collect_partitioned(self) -> (Vec<T>, Vec<E>)
Consume the pipeline and split all items into (ok_values, errors).
Processing continues even when errors are encountered — every element is examined, and errors are collected into the second vector.
実行種別: 即時実行
§Examples
use rinq::QueryBuilder;
let strings = vec!["1", "two", "3", "four", "5"];
let (ok, err) = QueryBuilder::from(strings)
.try_select(|s| s.parse::<i32>())
.collect_partitioned();
assert_eq!(ok, vec![1, 3, 5]);
assert_eq!(err.len(), 2);Sourcepub fn collect_results(self) -> Result<Vec<T>, E>
pub fn collect_results(self) -> Result<Vec<T>, E>
Consume the pipeline and return Ok(vec) if every item succeeded, or
Err(e) on the first failure (short-circuit, remaining items are dropped).
This mirrors the behaviour of ?-propagation and
Iterator::collect::<Result<Vec<_>, _>>().
実行種別: 即時実行
§Examples
use rinq::QueryBuilder;
// All succeed
let result = QueryBuilder::from(vec!["1", "2", "3"])
.try_select(|s| s.parse::<i32>())
.collect_results();
assert_eq!(result.unwrap(), vec![1, 2, 3]);
// First error short-circuits
let result = QueryBuilder::from(vec!["1", "oops", "3"])
.try_select(|s| s.parse::<i32>())
.collect_results();
assert!(result.is_err());Auto Trait Implementations§
impl<T, E> Freeze for TryQueryBuilder<T, E>
impl<T, E> !RefUnwindSafe for TryQueryBuilder<T, E>
impl<T, E> !Send for TryQueryBuilder<T, E>
impl<T, E> !Sync for TryQueryBuilder<T, E>
impl<T, E> Unpin for TryQueryBuilder<T, E>
impl<T, E> UnsafeUnpin for TryQueryBuilder<T, E>
impl<T, E> !UnwindSafe for TryQueryBuilder<T, E>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more