Ensures that the given iterator satisfies provided validator for each successful item. In case of an error, `Err(E)` will be emitted.
(iter: I, mut validator: V)
| 155 | /// Ensures that the given iterator satisfies provided validator for each successful item. |
| 156 | /// In case of an error, `Err(E)` will be emitted. |
| 157 | pub fn try_validate<I, OK, E, V>(iter: I, mut validator: V) -> impl Iterator<Item = Result<OK, E>> |
| 158 | where |
| 159 | I: IntoIterator<Item = Result<OK, E>>, |
| 160 | V: SeqValidator<OK>, |
| 161 | E: From<V::Failure>, |
| 162 | { |
| 163 | iter.into_iter().map(move |res| { |
| 164 | let item = res?; |
| 165 | |
| 166 | if let Some(failure) = validator.validate(&item) { |
| 167 | Err(failure.into()) |
| 168 | } else { |
| 169 | Ok(item) |
| 170 | } |
| 171 | }) |
| 172 | } |