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

Change return type of unstable Waker::noop() from Waker to &Waker. #119984

Merged
merged 2 commits into from
Jan 20, 2024

Commits on Jan 17, 2024

  1. Change return type of unstable Waker::noop() from Waker to &Waker.

    The advantage of this is that it does not need to be assigned to a
    variable to be used in a `Context` creation, which is the most common
    thing to want to do with a noop waker.
    
    If an owned noop waker is desired, it can be created by cloning, but the
    reverse is harder. Alternatively, both versions could be provided, like
    `futures::task::noop_waker()` and `futures::task::noop_waker_ref()`, but
    that seems to me to be API clutter for a very small benefit, whereas
    having the `&'static` reference available is a large benefit.
    
    Previous discussion on the tracking issue starting here:
    rust-lang#98286 (comment)
    kpreid committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    6f8a944 View commit details
    Browse the repository at this point in the history
  2. Remove unnecessary lets and borrowing from Waker::noop() usage.

    `Waker::noop()` now returns a `&'static Waker` reference, so it can be
    passed directly to `Context` creation with no temporary lifetime issue.
    kpreid committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    c48cdfe View commit details
    Browse the repository at this point in the history