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

Introduce stream::select_with_strategy #2450

Merged
merged 7 commits into from Jun 17, 2021

Commits on Jun 8, 2021

  1. Introduce futures_util::stream::select_bias.

    The current select function only supports round robin. To change that
    would be a breaking change, so for now I propose a `select_bias` which
    takes a closure that defines the selection strategy.
    
    - When a breaking change is planned, we could re-consider this, but it
      does have 4 generic parameters of which one is a closure, compared to
      the 2 streams in `select`.
    - note the name select_bias. It's not consistent with `select_biased` used
      elsewhere in the lib. This can obviously be changed, but I feel the "ed"
      at the end does not add any semantic value but makes function names
      longer.
    - There isn't really integration tests included right now, but the examples
      in the docs get tested by doc test.
    najamelan committed Jun 8, 2021
    Copy the full SHA
    b5bd8fe View commit details
    Browse the repository at this point in the history

Commits on Jun 16, 2021

  1. Fix review feedback.

    najamelan committed Jun 16, 2021
    Copy the full SHA
    9a66962 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    ebe59eb View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    37f2dee View commit details
    Browse the repository at this point in the history
  4. Please cargo fmt...

    najamelan committed Jun 16, 2021
    Copy the full SHA
    0aab927 View commit details
    Browse the repository at this point in the history

Commits on Jun 17, 2021

  1. Copy the full SHA
    34c4a00 View commit details
    Browse the repository at this point in the history
  2. Give SelectWithStrategy a custom fmt::Debug impl.

    This allows not to print the closure and give `Select` a derive impl.
    
    The result for `Select` looks like:
    
    `Select { inner: SelectWithStrategy { stream1: Fuse { stream: Repeat { item: 1 }, done: false }, stream2: Fuse { stream: Repeat { item: 2 }, done: false } } }`
    najamelan committed Jun 17, 2021
    Copy the full SHA
    e8a17f9 View commit details
    Browse the repository at this point in the history