I'm just not seeing how this disjointness can be done at a practical level. The apply_turn
function, regardless of where it resides, needs to have access to a mutable State
. Something has to determine which fields are to be modified, and then modify them. The only way that thing can access those fields is if it has access to a mutable state.
Consider the top-level game loop:
loop {
read_state( &mut state );
let turn = eval_turn( &state );
state.apply_turn( turn );
}
apply_turn
needs a mutable state object, otherwise it can't work. How can I create disjoint functions without just inlining the apply_turn
function?