Created
May 11, 2022 09:29
-
-
Save linkdd/48c3be67a1e283d1a7909e110e0a3771 to your computer and use it in GitHub Desktop.
Return Rust generator from function
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
use genawaiter::{sync::gen, yield_, Generator}; | |
type MyGen = Box<dyn Generator<Yield = i32, Return = i32>>; | |
fn make_generator() -> MyGen { | |
let gen = gen!({ | |
yield_!(1); | |
yield_!(2); | |
yield_!(3); | |
4 | |
}); | |
Box::new(gen) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment