@@ -914,6 +914,45 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<PinBox<U>> for PinBox<T> {}
914914#[ unstable( feature = "pin" , issue = "49150" ) ]
915915impl < T : ?Sized > Unpin for PinBox < T > { }
916916
917+ #[ unstable( feature = "futures_api" , issue = "50547" ) ]
918+ impl < ' a , F : ?Sized + Future + Unpin > Future for Box < F > {
919+ type Output = F :: Output ;
920+
921+ fn poll ( mut self : PinMut < Self > , cx : & mut Context ) -> Poll < Self :: Output > {
922+ PinMut :: new ( & mut * * self ) . poll ( cx)
923+ }
924+ }
925+
926+ #[ unstable( feature = "futures_api" , issue = "50547" ) ]
927+ impl < ' a , F : ?Sized + Future > Future for PinBox < F > {
928+ type Output = F :: Output ;
929+
930+ fn poll ( mut self : PinMut < Self > , cx : & mut Context ) -> Poll < Self :: Output > {
931+ self . as_pin_mut ( ) . poll ( cx)
932+ }
933+ }
934+
935+ #[ unstable( feature = "futures_api" , issue = "50547" ) ]
936+ unsafe impl < F : Future < Output = ( ) > + Send + ' static > UnsafePoll for Box < F > {
937+ fn into_raw ( self ) -> * mut ( ) {
938+ unsafe {
939+ mem:: transmute ( self )
940+ }
941+ }
942+
943+ unsafe fn poll ( task : * mut ( ) , cx : & mut Context ) -> Poll < ( ) > {
944+ let ptr: * mut F = mem:: transmute ( task) ;
945+ let pin: PinMut < F > = PinMut :: new_unchecked ( & mut * ptr) ;
946+ pin. poll ( cx)
947+ }
948+
949+ unsafe fn drop ( task : * mut ( ) ) {
950+ let ptr: * mut F = mem:: transmute ( task) ;
951+ let boxed = Box :: from_raw ( ptr) ;
952+ drop ( boxed)
953+ }
954+ }
955+
917956#[ unstable( feature = "futures_api" , issue = "50547" ) ]
918957unsafe impl < F : Future < Output = ( ) > + Send + ' static > UnsafePoll for PinBox < F > {
919958 fn into_raw ( self ) -> * mut ( ) {
0 commit comments