@@ -3,7 +3,7 @@ use std::io;
33#[ cfg( any( feature = "std" , feature = "async_std" ) ) ]
44use unsafe_io:: AsUnsafeFile ;
55#[ cfg( feature = "async_std" ) ]
6- use unsafe_io:: { FromUnsafeFile , IntoUnsafeFile } ;
6+ use unsafe_io:: FromUnsafeFile ;
77
88/// A trait for the `reopen` function.
99pub trait Reopen {
@@ -58,8 +58,7 @@ impl Reopen for async_std::fs::File {
5858 #[ inline]
5959 fn reopen ( & self , options : & OpenOptions ) -> io:: Result < Self > {
6060 let file = reopen ( & self . as_file_view ( ) , options) ?;
61- let unsafe_file = file. into_unsafe_file ( ) ;
62- Ok ( unsafe { async_std:: fs:: File :: from_unsafe_file ( unsafe_file) } )
61+ Ok ( async_std:: fs:: File :: from_filelike ( file) )
6362 }
6463}
6564
@@ -68,8 +67,8 @@ impl Reopen for cap_async_std::fs::File {
6867 #[ inline]
6968 fn reopen ( & self , options : & OpenOptions ) -> io:: Result < Self > {
7069 let file = reopen ( & self . as_file_view ( ) , options) ?;
71- let unsafe_file = file . into_unsafe_file ( ) ;
72- Ok ( unsafe { Self :: from_std ( async_std :: fs :: File :: from_unsafe_file ( unsafe_file ) ) } )
70+ let std = async_std :: fs :: File :: from_filelike ( file ) ;
71+ Ok ( unsafe { Self :: from_std ( std ) } )
7372 }
7473}
7574
@@ -78,7 +77,7 @@ impl Reopen for cap_async_std::fs_utf8::File {
7877 #[ inline]
7978 fn reopen ( & self , options : & OpenOptions ) -> io:: Result < Self > {
8079 let file = reopen ( & self . as_file_view ( ) , options) ?;
81- let unsafe_file = file . into_unsafe_file ( ) ;
82- Ok ( unsafe { Self :: from_std ( async_std :: fs :: File :: from_unsafe_file ( unsafe_file ) ) } )
80+ let std = async_std :: fs :: File :: from_filelike ( file ) ;
81+ Ok ( unsafe { Self :: from_std ( std ) } )
8382 }
8483}
0 commit comments