pub fn fold<Item, Err, Func>(
    accumulator: T,
    list: impl Iterator<Item = Item>,
    func: Func,
  ) -> BatchResult<T>
  where
    Func: Fn(&mut T, Item) -> Result<(), Err>,
    Err: Display + Debug + Send + Sync + 'static,
  {
    list.fold(BatchResult::new(accumulator), |mut acc, item| {
      acc.count += 1;
      let res = func(&mut acc.value, item);
      if let Err(err) = res {
        acc.append(anyhow!(err));
      }
      acc
    })
  }
/// Uses a function to apply each item to the accumulator, storing errors for future examination
///
/// Please note, errors have the potential to corrupt the accumulator since it mutates
Uses a function to apply each item to the accumulator, storing errors for future examination
Please note, errors have the potential to corrupt the accumulator since it mutates
Uses a function to apply each item to the accumulator storing errors for future examination Please note errors have the potential to corrupt the accumulator since it mutates
pub fn fold<Item, Err, Func>(
    accumulator: T,
    list: impl Iterator<Item = Item>,
    func: Func,
  ) -> BatchResult<T>
  where
    Func: Fn(&mut T, Item) -> Result<(), Err>,
    Err: Display + Debug + Send + Sync + 'static,
  {
    list.fold(BatchResult::new(accumulator), |mut acc, item| {
      acc.count += 1;
      let res = func(&mut acc.value, item);
      if let Err(err) = res {
        acc.append(anyhow!(err));
      }
      acc
    })
  }
pub fn fold < Item , Err , Func > ( accumulator : T , list : impl Iterator < Item = Item > , func : Func , ) -> BatchResult < T > where Func : Fn ( & mut T , Item ) -> Result < ( ) , Err > , Err : Display + Debug + Send + Sync + ' static , { list . fold ( BatchResult :: new ( accumulator ) , | mut acc , item | { acc . count += 1 ; let res = func ( & mut acc . value , item ) ; if let Err ( err ) = res { acc . append ( anyhow ! ( err ) ) ; } acc } ) }
Uses a function to apply each item to the accumulator, storing errors for future examination
Please note, errors have the potential to corrupt the accumulator since it mutates
Uses a function to apply each item to the accumulator storing errors for future examination Please note errors have the potential to corrupt the accumulator since it mutates
accumulator
T
list
impl Iterator<Item = Item>
func
Func
accumulator
T
list
impl Iterator<Item = Item>
func
Func