-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gobbled value in generator #35
Comments
I can't say whether this is intentional, but I believe what's happening is that the initial state returned by
This aligns with how rust async functions work in that no work is performed until an await occurs, so in that sense the behavior tracks. However, the genawaiter doc page contains:
which confuses users as in reality this only prints "world". |
I understand that there ought to be a method to move the generator from "unstarted" to the first value-accepting
Maybe we need to expose the two states of the generator:
|
I agree that an API which doesn't discard arguments would be preferable. I will note, though, that the documentation does at least say that "the first resume argument will be lost." |
Thank you! I wasn't aware of this bit of documentation. This at least confirm that the behavior is intended. It is unfortunate, however. As a user, it means my My concrete case here is an infinite looping generator that takes commands via resume, and returns results. The Types containing "dummy values" strike me as unidiomatic Rust, and can lead to error (such as clients sending the I'm not sure what we could do here without breaking backcompatibility though. |
Thank you for making
genawaiter
!Configuration
Code
Expected output:
or at least,
Observed output
It looks like the first value passed to the generator is never printed? I'm not sure why that is.
Is there something I'm misunderstanding?
The text was updated successfully, but these errors were encountered: