/// Applies all entity operations to the given entity in order.
/// `ops` must not contain any `AbortUnless` operations.
Applies all entity operations to the given entity in order.
`ops` must not contain any `AbortUnless` operations.
Applies all entity operations to the given entity in order . ` ops ` must not contain any ` AbortUnless ` operations .
pub fn apply_all(
        entity: Option<Entity>,
        ops: &[&EntityOperation],
    ) -> Result<Option<Entity>, Error> {
        use self::EntityOperation::*;
        // Only continue if all operations are Set/Remove.
        ops.iter().try_for_each(|op| match op {
            Set { .. } | Remove { .. } | Update { .. } => Ok(()),
            AbortUnless { .. } => Err(format_err!("Cannot apply {:?} to an Entity", op)),
        })?;
        // If there is a remove operations, we only need to consider the operations after that
        ops.iter()
            .rev()
            .take_while(|op| !op.is_remove())
            .collect::<Vec<_>>()
            .iter()
            .rev()
            .try_fold(entity, |entity, op| op.apply(entity))
    }
pub fn apply_all ( entity : Option < Entity > , ops : & [ & EntityOperation ] , ) -> Result < Option < Entity > , Error > { use self :: EntityOperation :: * ; // Only continue if all operations are Set/Remove. ops . iter ( ) . try_for_each ( | op | match op { Set { .. } | Remove { .. } | Update { .. } => Ok ( ( ) ) , AbortUnless { .. } => Err ( format_err ! ( " " op ) ) , } ) ? ; // If there is a remove operations, we only need to consider the operations after that ops . iter ( ) . rev ( ) . take_while ( | op | ! op . is_remove ( ) ) . collect :: < Vec < _ > > ( ) . iter ( ) . rev ( ) . try_fold ( entity , | entity , op | op . apply ( entity ) ) }
Applies all entity operations to the given entity in order.
Applies all entity operations to the given entity in order .
entity
Option<Entity>
ops
&[&EntityOperation]