-
Notifications
You must be signed in to change notification settings - Fork 30
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 stream::from_fn
#123
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR. This feature is currently not tested in CI, so could you add futures-lite/.github/workflows/ci.yml Lines 56 to 58 in 5c196b9
|
Initially I added |
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.
My main concern is the use of the feature flag. Is there a case where I can write a crate using futures-lite
with this feature flag turned off, that can then fail to compile if another crate in the dependency tree turns it on?
Yes, this code will compile without the feature and will not with it: fn a<F, U>(f: F) -> impl Stream<Item = u8>
where
F: FnMut() -> U,
U: Future<Output = u8>,
{
stream::from_fn(f)
// the trait `AsyncFnMut()` is not implemented for `F`
} I expected it to work, but at the moment this is a problem |
This adds an analogue of
std::iter::from_fn
for streams.Also creates a new feature
async-closure
that allows to use newer compiler version 1.85 or later to use async closures. Crates for older versions may use this function without the feature but it'll be more limited.