-
Notifications
You must be signed in to change notification settings - Fork 628
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
feat: Add sink::unfold #2268
feat: Add sink::unfold #2268
Conversation
A more general function than `from_fn` (rust-lang#2254), as suggested in rust-lang#2254 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me. I think we'll deprecate this and add something like #2254 once async closures became working properly, but for now, this is more flexible and I prefer this than #2254. (AFAIK, no one is currently working on async closures, so I don't think async closures' problems will be fixed soon.)
cc @cramertj @Nemo157: Any opinion on adding this? (I tend to merge this)
state: Option<T>, | ||
function: F, | ||
#[pin] | ||
future: Option<R>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state
and future
are never present at the same time, so maybe the use of an enum could reduce the size of the struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would accept a patch to reduce the size of unfold
.
The way how this is implemented is slightly suboptimal for type inference, see #2311 |
A more general function than
from_fn
(#2254), as suggested in#2254 (comment)