Skip to content
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

Merged
merged 2 commits into from
Dec 8, 2020
Merged

feat: Add sink::unfold #2268

merged 2 commits into from
Dec 8, 2020

Conversation

Marwes
Copy link
Contributor

@Marwes Marwes commented Nov 23, 2020

A more general function than from_fn (#2254), as suggested in
#2254 (comment)

A more general function than `from_fn` (rust-lang#2254), as suggested in
rust-lang#2254 (comment)
@Marwes Marwes mentioned this pull request Nov 23, 2020
Copy link
Member

@taiki-e taiki-e left a 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>,

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?

Copy link
Member

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.

@taiki-e taiki-e merged commit cb52c5e into rust-lang:master Dec 8, 2020
@Marwes Marwes deleted the sink_unfold branch December 8, 2020 09:36
@taiki-e taiki-e added A-sink Area: futures::sink and removed C-feature-request labels Jan 6, 2021
@taiki-e taiki-e mentioned this pull request Jan 8, 2021
@sdroege
Copy link
Contributor

sdroege commented Jan 12, 2021

The way how this is implemented is slightly suboptimal for type inference, see #2311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sink Area: futures::sink
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants