arr-rs 0.6.0

arr-rs - rust arrays library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::errors::ArrayError;

pub(crate) trait ValidateHasError where Self: Sized {

    fn has_error(&self) -> Result<Self, ArrayError>;
}

impl <T: Clone> ValidateHasError for Vec<Result<T, ArrayError>> {

    fn has_error(&self) -> Result<Self, ArrayError> {
        self.iter()
            .find(|a| a.is_err())
            .map_or_else(
            || Ok(self.clone()),
            |error| Err(error.clone().err().unwrap()))
    }
}