diff --git a/src/ship/items/transaction.rs b/src/ship/items/transaction.rs index a161a2a..805f6d1 100644 --- a/src/ship/items/transaction.rs +++ b/src/ship/items/transaction.rs @@ -38,11 +38,8 @@ impl<'a, EG: EntityGateway> ItemTransactionActions<'a, EG> { } } - pub fn action + 'static>(&mut self, action: A) { - //pub fn action>>>(&mut self, action: A) { - //pub fn action(&mut self, action: impl ItemAction) { - self.action_queue.push(Box::new(action)) - //self.action_queue.push(action.into()) + pub fn action(&mut self, action: Box>) { + 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)