|
|
@ -38,11 +38,8 @@ impl<'a, EG: EntityGateway> ItemTransactionActions<'a, EG> { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn action<A: ItemAction<EG> + 'static>(&mut self, action: A) {
|
|
|
|
//pub fn action<A: Into<Box<dyn ItemAction<EG>>>>(&mut self, action: A) {
|
|
|
|
//pub fn action(&mut self, action: impl ItemAction<EG>) {
|
|
|
|
self.action_queue.push(Box::new(action))
|
|
|
|
//self.action_queue.push(action.into())
|
|
|
|
pub fn action(&mut self, action: Box<dyn ItemAction<EG>>) {
|
|
|
|
self.action_queue.push(action)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
@ -226,9 +223,9 @@ mod test { |
|
|
|
|
|
|
|
let result = ItemTransaction::new(&item_manager, 12)
|
|
|
|
.act(|it, k| {
|
|
|
|
it.action(DummyAction1 {name: "asdf".into()});
|
|
|
|
it.action(DummyAction2 {value: 11});
|
|
|
|
it.action(DummyAction2 {value: *k});
|
|
|
|
it.action(Box::new(DummyAction1 {name: "asdf".into()}));
|
|
|
|
it.action(Box::new(DummyAction2 {value: 11}));
|
|
|
|
it.action(Box::new(DummyAction2 {value: *k}));
|
|
|
|
if *k == 99 {
|
|
|
|
return Err(DummyError::Error)
|
|
|
|
}
|
|
|
@ -300,9 +297,9 @@ mod test { |
|
|
|
|
|
|
|
let result = ItemTransaction::new(&item_manager, 12)
|
|
|
|
.act(|it, _| -> Result<(), _> {
|
|
|
|
it.action(DummyAction1 {});
|
|
|
|
it.action(DummyAction2 {});
|
|
|
|
it.action(DummyAction2 {});
|
|
|
|
it.action(Box::new(DummyAction1 {}));
|
|
|
|
it.action(Box::new(DummyAction2 {}));
|
|
|
|
it.action(Box::new(DummyAction2 {}));
|
|
|
|
Err(DummyError::Error)
|
|
|
|
})
|
|
|
|
.commit(&mut item_manager, &mut entity_gateway)
|
|
|
@ -368,9 +365,9 @@ mod test { |
|
|
|
|
|
|
|
let result = ItemTransaction::new(&item_manager, 12)
|
|
|
|
.act(|it, _| -> Result<_, DummyError> {
|
|
|
|
it.action(DummyAction1 {});
|
|
|
|
it.action(DummyAction2 {});
|
|
|
|
it.action(DummyAction2 {});
|
|
|
|
it.action(Box::new(DummyAction1 {}));
|
|
|
|
it.action(Box::new(DummyAction2 {}));
|
|
|
|
it.action(Box::new(DummyAction2 {}));
|
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.commit(&mut item_manager, &mut entity_gateway)
|
|
|
|