Skip to main content

TryQueryBuilder

Struct TryQueryBuilder 

Source
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:

Implementations§

Source§

impl<T, E> TryQueryBuilder<T, E>

Source

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);
Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.