(self)
| 375 | type Error = E; |
| 376 | |
| 377 | fn collect_all_errors<Collection: FromIterator<Self::Item>>(self) -> Result<Collection, ErrorStream<Self::Error>> { |
| 378 | // not in a valid state: contains no errors! |
| 379 | let mut all_errors = ErrorStream(Default::default()); |
| 380 | |
| 381 | let collection = self |
| 382 | .filter_map(|result| match result { |
| 383 | Ok(value) => Some(value), |
| 384 | Err(errors) => { |
| 385 | all_errors.extend(errors); |
| 386 | None |
| 387 | } |
| 388 | }) |
| 389 | .collect::<Collection>(); |
| 390 | |
| 391 | if all_errors.0.is_empty() { |
| 392 | // invalid state is not returned. |
| 393 | Ok(collection) |
| 394 | } else { |
| 395 | // not empty, so we're good to return it. |
| 396 | Err(all_errors) |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | /// Helper macro to match against an error stream, expecting a specific error. |
no test coverage detected