-
Notifications
You must be signed in to change notification settings - Fork 635
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::from_fn #2254
feat: Add sink::from_fn #2254
Conversation
Felt the need for this a couple times to mock a sink or inject something that is sink-like, but doesn't implement sink itself.
See previously #1493, actually capturing state inside the closure is painful. Comparing the implementations I see two bugs here:
|
A mutex does the trick when that is necessary 🤷 . There are also cases where there isn't a need to capture state (say pushing to an external database. |
I have no objection to adding a way to convert However, I'm not clear if this implementation is preferred. We tried to add something similar to stream (#1609 #1842), but we decided that it would be preferable to provide only So, I'm starting to feel that adding an API like |
A more general function than `from_fn` (rust-lang#2254), as suggested in rust-lang#2254 (comment)
Closing this in favor of #2268. |
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)
A more general function than `from_fn` (rust-lang#2254), as suggested in rust-lang#2254 (comment)
Felt the need for this a couple times to mock a sink or inject something
that is sink-like, but doesn't implement sink itself.