crcnt_ddd 0.2.4

CRCNT DDD Basic Objects
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
pub fn merge_results<T: Clone, E: Clone>(xs: Vec<Result<T, E>>) -> Result<Vec<T>, E> {
  let init: Vec<T> = vec![];
  xs.iter().fold(Ok(init), |acc, next| {
             let acc = acc.and_then(|mut xs| {
                            let next = next.clone();
                            next.map(|x| {
                                  xs.push(x.clone());
                                  xs
                                })
                          });
             acc
           })
}