Rollup merge of #84453 - notriddle:waker-from-docs, r=cramertj

Document From implementations for Waker and RawWaker

CC #51430
This commit is contained in:
Yuki Okushi 2021-04-24 12:17:06 +09:00 committed by GitHub
commit ed5646bfee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,6 +87,9 @@ fn wake_by_ref(self: &Arc<Self>) {
#[stable(feature = "wake_trait", since = "1.51.0")]
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for Waker {
/// Use a `Wake`-able type as a `Waker`.
///
/// No heap allocations or atomic operations are used for this conversion.
fn from(waker: Arc<W>) -> Waker {
// SAFETY: This is safe because raw_waker safely constructs
// a RawWaker from Arc<W>.
@ -96,6 +99,9 @@ fn from(waker: Arc<W>) -> Waker {
#[stable(feature = "wake_trait", since = "1.51.0")]
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for RawWaker {
/// Use a `Wake`-able type as a `RawWaker`.
///
/// No heap allocations or atomic operations are used for this conversion.
fn from(waker: Arc<W>) -> RawWaker {
raw_waker(waker)
}