expression
Separate transition decisions from external effects
A pure transition function can describe an intended side effect without performing it. This supports deterministic tests of state and intent. Applying an effect can still fail, so production code needs an explicit delivery, failure and retry policy. Here the effect is only printed; no notification is sent. Expected result (NOT RUN): Notify, None Common mistake: Treating a pure decision or a suppressed duplicate as proof of exactly-once external delivery. Static Rust example; not a verified ByteMind executable assessment.
Formal Syntax & Structure
rust syntaxrust
fn decide(state: State, event: Event) -> (State, Effect)Working Example
Example Snippetrust
#[derive(Debug, Clone, Copy)]enum State { Pending, Completed }enum Event { Finish }#[derive(Debug)]enum Effect { Notify, None }fn decide(state: State, event: Event) -> (State, Effect) { match (state, event) { (State::Pending, Event::Finish) => (State::Completed, Effect::Notify), (State::Completed, Event::Finish) => (State::Completed, Effect::None), }}fn main() { let (state, first) = decide(State::Pending, Event::Finish); let (_, second) = decide(state, Event::Finish); println!("{first:?}, {second:?}");}