You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For built-in data structures, it might sometimes be useful to be able to atomically perform multiple operations. I'd need to give some thought to the best way to do this, but one idea is to have a Transactioned pseudo-data structure that wraps a state machine and accepts a Transaction update. Something like (not tested):
pub struct Transaction<T: Transition>(Vec<T>);
pub struct Transactioned<T: StateMachine>(T);
impl<T: StateMachine> StateMachine for Transactioned<T> {
type Transition = Transactioned<<T as StateMachine>::Transition>;
fn apply(&mut self, transition: Self::Transition) {
for t in transition.0 {
self.0.apply(t);
}
}
}
The text was updated successfully, but these errors were encountered:
The more I think about it, the more I think transactions are the wrong approach. The need for transactions implies that a user intent could result in multiple state transitions, but the correct way to model that is for the user intent to represent one state transition that captures both actions.
For built-in data structures, it might sometimes be useful to be able to atomically perform multiple operations. I'd need to give some thought to the best way to do this, but one idea is to have a
Transactioned
pseudo-data structure that wraps a state machine and accepts aTransaction
update. Something like (not tested):The text was updated successfully, but these errors were encountered: