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

Accept async functions for StreamExt::map() and others #48

Open
aryan9600 opened this issue Dec 15, 2021 · 3 comments
Open

Accept async functions for StreamExt::map() and others #48

aryan9600 opened this issue Dec 15, 2021 · 3 comments

Comments

@aryan9600
Copy link

aryan9600 commented Dec 15, 2021

The StreamExt::map(), StreamExt::filter_map() in the futures crate accepts async functions which resolve to an <T>/Option<T>, whereas the same methods in the futures-lite crate accept normal functions which are meant to return <T>/Option<T>. (there are other similar methods as well)

I don't know if this is by design or a mistake, but since this crate is supposed to be fully compatible with the futures crate, I think these methods should be changed accordingly.

@aryan9600 aryan9600 changed the title Accept async functions for StreamExt::filter() and others Accept async functions for StreamExt::map() and others Dec 15, 2021
@taiki-e
Copy link
Collaborator

taiki-e commented Dec 15, 2021

The current behavior is what was intended by the original author of this crate.

rust-lang/futures-rs#1987 (comment)

since this crate is supposed to be fully compatible with the futures crate

Full compatibility is about traits such as streams, not about method signatures. Readme also says:

fixes minor warts in its API, fills in some obvious gaps

@aryan9600
Copy link
Author

aryan9600 commented Dec 15, 2021

I see. Would adding async closures for these methods be considered? (especially if they don't affect compile times that much)

@notgull
Copy link
Member

notgull commented Apr 8, 2023

The usual strategy is to use the then() combinator to evaluate an async closure, and then use the result of that in filter_map(), map() etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants