use std::ops::ControlFlow; pub trait Step { type Error; fn step(&mut self, context: &mut Ctx) -> Result, Self::Error>; fn finish(&mut self, context: &mut Ctx) -> Result { loop { if let ControlFlow::Break(outcome) = self.step(context)? { return Ok(outcome); } } } } pub trait StepBack { fn step_back(&mut self, context: &mut C) -> Result; } pub trait Abort { fn abort(&mut self, context: &mut C); }