fn main () { use ::next_gen::prelude::*; #[generator(u8)] fn countdown (count: u8, value: Ret) -> Ret { let mut current = count; while let Some(next) = current.checked_sub(1) { yield_!(current); current = next; } value } mk_gen!(let mut generator = countdown(3, "Boom!")); let mut next = || generator.as_mut().resume(); assert_eq!(next(), GeneratorState::Yield(3)); assert_eq!(next(), GeneratorState::Yield(2)); assert_eq!(next(), GeneratorState::Yield(1)); assert_eq!(next(), GeneratorState::Return("Boom!")); }