Rust generators: exploration of potential syntax

I was convinced by this post up-thread. If you have uniform Yield and Return types, it's just noise. If you have a () return type, you just use Option<Yield>. The same logic behind removing the Future::Error type makes sense for Generator::Return to me. Basically if you have different Yield and Return types, use Result<Yield, Return>; the language already has algebraic types, so why special case Generator by forcing a sumtype if Option<T> just ends up being more idiomatic anyways?

2 Likes