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

Delegate Future implementation to Next struct #1372

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Sep 16, 2021

  1. Delegate Future implementation to Next struct

    Previously, reading values out of Subscriber asynchronously would
    involve awaiting an &mut Subscriber, which causes re-polling the
    same future after it yields a value. This is considered 'improper'
    for a Future, and more closely maps to the Stream trait.
    Unfortunately, Stream has not been standardized and so implementing
    that trait would require pulling in the 'futures' dependency, which
    is not yet 1.0 and subject to change. Instead, this implements a
    Stream-like poll_next method on Subscriber, and exposes that from
    an implementation of Future for a new Next<'_> type, which can be
    constructed by calling '.next()' on a Subscriber. This allows for
    a more traditional interaction with futures that mimics how other
    libraries produce values.
    
    Note that it is still possible to indefinitely poll on an
    &mut Next<'_> type to pull every value out of the subscriber, but
    it is less intuitive to perform that operation and it likely won't
    occur in downstream projects.
    asonix committed Sep 16, 2021
    Configuration menu
    Copy the full SHA
    9b57356 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    da7eb26 View commit details
    Browse the repository at this point in the history
  3. Fix doctest

    asonix committed Sep 16, 2021
    Configuration menu
    Copy the full SHA
    bd3697f View commit details
    Browse the repository at this point in the history