MCPcopy Create free account
hub / github.com/hashintel/hash / try_process_reports

Function try_process_reports

libs/error-stack/src/ext/iter.rs:62–83  ·  view source on GitHub ↗
(
    iter: I,
    bound: Option<usize>,
    mut collect: F,
)

Source from the content-addressed store, hash-verified

60}
61
62fn try_process_reports<I, T, R, C, F, U>(
63 iter: I,
64 bound: Option<usize>,
65 mut collect: F,
66) -> Result<U, Report<[C]>>
67where
68 I: Iterator<Item = Result<T, R>>,
69 R: Into<Report<[C]>>,
70 for<'a> F: FnMut(ReportShunt<'a, I, T, C>) -> U,
71{
72 let mut report = None;
73 let shunt = ReportShunt {
74 iter,
75 report: &mut report,
76 context_len: 0,
77 context_bound: bound.unwrap_or(usize::MAX),
78 _marker: core::marker::PhantomData,
79 };
80
81 let value = collect(shunt);
82 report.map_or_else(|| Ok(value), |report| Err(report))
83}
84
85/// An extension trait for iterators that enables error-aware collection of items.
86///

Callers 2

try_collect_reportsMethod · 0.85

Calls 3

OkInterface · 0.85
ErrInterface · 0.85
collectFunction · 0.50

Tested by

no test coverage detected