Made from_waker, waker, from_raw const

This commit is contained in:
y86-dev
2022-09-14 14:15:44 +02:00
parent c97922dca5
commit 9a78faba71
6 changed files with 26 additions and 4 deletions

View File

@@ -186,17 +186,19 @@ pub struct Context<'a> {
impl<'a> Context<'a> {
/// Create a new `Context` from a [`&Waker`](Waker).
#[stable(feature = "futures_api", since = "1.36.0")]
#[rustc_const_unstable(feature = "const_waker", issue = "none")]
#[must_use]
#[inline]
pub fn from_waker(waker: &'a Waker) -> Self {
pub const fn from_waker(waker: &'a Waker) -> Self {
Context { waker, _marker: PhantomData }
}
/// Returns a reference to the [`Waker`] for the current task.
#[stable(feature = "futures_api", since = "1.36.0")]
#[rustc_const_unstable(feature = "const_waker", issue = "none")]
#[must_use]
#[inline]
pub fn waker(&self) -> &'a Waker {
pub const fn waker(&self) -> &'a Waker {
&self.waker
}
}
@@ -311,7 +313,8 @@ impl Waker {
#[inline]
#[must_use]
#[stable(feature = "futures_api", since = "1.36.0")]
pub unsafe fn from_raw(waker: RawWaker) -> Waker {
#[rustc_const_unstable(feature = "const_waker", issue = "none")]
pub const unsafe fn from_raw(waker: RawWaker) -> Waker {
Waker { waker }
}