smol-rs / futures-lite

Futures, streams, and async I/O combinators.
Apache License 2.0
427 stars 25 forks source link

reduce code duplication / unnecessary branches #74

Closed fogti closed 11 months ago

fogti commented 11 months ago

The first commit removes a duplication in the cache branching in block_on, by introducing temporary stack variables. It would be possible to use an enum instead of these two temporary variables, but it wouldn't have much benefit (while being harder to understand).

The second commit mostly changes TryZip to store only Ok results, omitting unnecessary branching on the unpacking before returning the zipped data. Unfortunately, this changes the type signature of TryZip and related functions.