Add `task::Waker::noop` by SabrinaJewson · Pull Request #96875 · rust-lang/rust...
source link: https://github.com/rust-lang/rust/pull/96875
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Conversation
Contributor
I have found myself reimplementing this function many times when I need a Context
but don't have a runtime or futures
to hand.
Prior art: futures::task::noop_waker
and futures::task::noop_waker_ref
Tracking issue: #98286
Unresolved questions:
- Should we also add
RawWaker::noop()
? (I don't think so, I can't think of a use case for it) - Should we also add
Context::noop()
? Depending on the future directionContext
goes a "noop context" might not even make sense in future. - Should it be an associated constant instead? That would allow for
let cx = &mut Context::from_waker(&Waker::NOOP);
to work on one line which is pretty nice. I don't really know what the guideline is here.
r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK