@@ -932,6 +932,25 @@ impl<F: ?Sized + Future> Future for PinBox<F> {
932932 }
933933}
934934
935+ #[ unstable( feature = "futures_api" , issue = "50547" ) ]
936+ unsafe impl < ' a , T , F > UnsafeFutureObj < ' a , T > for Box < F >
937+ where F : Future < Output = T > + ' a
938+ {
939+ fn into_raw ( self ) -> * mut ( ) {
940+ Box :: into_raw ( self ) as * mut ( )
941+ }
942+
943+ unsafe fn poll ( ptr : * mut ( ) , cx : & mut Context ) -> Poll < T > {
944+ let ptr = ptr as * mut F ;
945+ let pin: PinMut < F > = PinMut :: new_unchecked ( & mut * ptr) ;
946+ pin. poll ( cx)
947+ }
948+
949+ unsafe fn drop ( ptr : * mut ( ) ) {
950+ drop ( Box :: from_raw ( ptr as * mut F ) )
951+ }
952+ }
953+
935954#[ unstable( feature = "futures_api" , issue = "50547" ) ]
936955unsafe impl < ' a , T , F > UnsafeFutureObj < ' a , T > for PinBox < F >
937956 where F : Future < Output = T > + ' a
@@ -961,7 +980,7 @@ impl<'a, F: Future<Output = ()> + Send + 'a> From<PinBox<F>> for FutureObj<'a, (
961980#[ unstable( feature = "futures_api" , issue = "50547" ) ]
962981impl < ' a , F : Future < Output = ( ) > + Send + ' a > From < Box < F > > for FutureObj < ' a , ( ) > {
963982 fn from ( boxed : Box < F > ) -> Self {
964- FutureObj :: new ( PinBox :: from ( boxed) )
983+ FutureObj :: new ( boxed)
965984 }
966985}
967986
@@ -975,6 +994,6 @@ impl<'a, F: Future<Output = ()> + 'a> From<PinBox<F>> for LocalFutureObj<'a, ()>
975994#[ unstable( feature = "futures_api" , issue = "50547" ) ]
976995impl < ' a , F : Future < Output = ( ) > + ' a > From < Box < F > > for LocalFutureObj < ' a , ( ) > {
977996 fn from ( boxed : Box < F > ) -> Self {
978- LocalFutureObj :: new ( PinBox :: from ( boxed) )
997+ LocalFutureObj :: new ( boxed)
979998 }
980999}
0 commit comments