Skip to main content

apply_decision

Function apply_decision 

Source
pub fn apply_decision<M, C, E>(
    current_mode: M,
    decision: Decision<M, C, E>,
) -> (M, Vec<C>)
Expand description

Applies a decision to an owned current mode.

This helper is for runtimes that own the mode and want to move the target mode and commands out of a Decision without cloning.

use ready_active_safe::prelude::*;

let mode = "ready";
let decision: Decision<&str, &str, ()> = transition("active").emit("initialize");

let (mode, commands) = apply_decision(mode, decision);
assert_eq!(mode, "active");
assert_eq!(commands, vec!["initialize"]);