Created
July 6, 2016 23:41
-
-
Save erickt/4bbc86fde56629dbb4bbc34a8d83f763 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[generator] | |
fn gen_ints() -> usize { | |
let mut state = State1; | |
loop { | |
match state { | |
State1 => { | |
state = State2; | |
return Some(1); | |
} | |
State2 => { | |
state = State3 { y: 3 }; | |
return Some(2); | |
} | |
State3 { y } => { | |
let tmp = y + 1; | |
state = State4 { _return_slot: tmp }; | |
continue; | |
} | |
State4 { _return_slot } => { | |
let y = _return_slot; | |
state = End; | |
return Some(y); | |
} | |
End => { | |
return None; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment