From 044fe0f558aa62926e6de9a76b95e4a74c0b1f99 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sat, 25 Jan 2020 20:03:10 +0100 Subject: Add a resume type parameter to `Generator` --- src/liballoc/boxed.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/liballoc') diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 8735c2c8f36..04be86862ae 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -1103,6 +1103,7 @@ impl AsMut for Box { #[stable(feature = "pin", since = "1.33.0")] impl Unpin for Box {} +#[cfg(bootstrap)] #[unstable(feature = "generator_trait", issue = "43122")] impl Generator for Box { type Yield = G::Yield; @@ -1113,6 +1114,7 @@ impl Generator for Box { } } +#[cfg(bootstrap)] #[unstable(feature = "generator_trait", issue = "43122")] impl Generator for Pin> { type Yield = G::Yield; @@ -1123,6 +1125,28 @@ impl Generator for Pin> { } } +#[cfg(not(bootstrap))] +#[unstable(feature = "generator_trait", issue = "43122")] +impl + Unpin, R> Generator for Box { + type Yield = G::Yield; + type Return = G::Return; + + fn resume(mut self: Pin<&mut Self>, arg: R) -> GeneratorState { + G::resume(Pin::new(&mut *self), arg) + } +} + +#[cfg(not(bootstrap))] +#[unstable(feature = "generator_trait", issue = "43122")] +impl, R> Generator for Pin> { + type Yield = G::Yield; + type Return = G::Return; + + fn resume(mut self: Pin<&mut Self>, arg: R) -> GeneratorState { + G::resume((*self).as_mut(), arg) + } +} + #[stable(feature = "futures_api", since = "1.36.0")] impl Future for Box { type Output = F::Output; -- cgit 1.4.1-3-g733a5