Skip to content

Commit

Permalink
Document why Waker::noop()'s implementation is the shape it is.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Jan 15, 2024
1 parent 219b00d commit 7052188
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/core/src/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ impl Waker {
#[must_use]
#[unstable(feature = "noop_waker", issue = "98286")]
pub const fn noop() -> &'static Waker {
// Ideally all this data would be explicitly `static` because it is used by reference and
// only ever needs one copy. But `const fn`s (and `const` items) cannot refer to statics,
// even though their values can be promoted to static. (That might change; see #119618.)
// An alternative would be a `pub static NOOP: &Waker`, but associated static items are not
// currently allowed either, and making it non-associated would be unergonomic.
const VTABLE: RawWakerVTable = RawWakerVTable::new(
// Cloning just returns a new no-op raw waker
|_| RAW,
Expand Down

0 comments on commit 7052188

Please sign in to comment.