@@ -932,6 +932,25 @@ impl<F: ?Sized + Future> Future for PinBox<F> {
932
932
}
933
933
}
934
934
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
+
935
954
#[ unstable( feature = "futures_api" , issue = "50547" ) ]
936
955
unsafe impl < ' a , T , F > UnsafeFutureObj < ' a , T > for PinBox < F >
937
956
where F : Future < Output = T > + ' a
@@ -961,7 +980,7 @@ impl<'a, F: Future<Output = ()> + Send + 'a> From<PinBox<F>> for FutureObj<'a, (
961
980
#[ unstable( feature = "futures_api" , issue = "50547" ) ]
962
981
impl < ' a , F : Future < Output = ( ) > + Send + ' a > From < Box < F > > for FutureObj < ' a , ( ) > {
963
982
fn from ( boxed : Box < F > ) -> Self {
964
- FutureObj :: new ( PinBox :: from ( boxed) )
983
+ FutureObj :: new ( boxed)
965
984
}
966
985
}
967
986
@@ -975,6 +994,6 @@ impl<'a, F: Future<Output = ()> + 'a> From<PinBox<F>> for LocalFutureObj<'a, ()>
975
994
#[ unstable( feature = "futures_api" , issue = "50547" ) ]
976
995
impl < ' a , F : Future < Output = ( ) > + ' a > From < Box < F > > for LocalFutureObj < ' a , ( ) > {
977
996
fn from ( boxed : Box < F > ) -> Self {
978
- LocalFutureObj :: new ( PinBox :: from ( boxed) )
997
+ LocalFutureObj :: new ( boxed)
979
998
}
980
999
}
0 commit comments