File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -150,10 +150,7 @@ impl File {
150150 /// [`read_to_end`]: fn@crate::io::AsyncReadExt::read_to_end
151151 /// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
152152 pub async fn open ( path : impl AsRef < Path > ) -> io:: Result < File > {
153- let path = path. as_ref ( ) . to_owned ( ) ;
154- let std = asyncify ( || StdFile :: open ( path) ) . await ?;
155-
156- Ok ( File :: from_std ( std) )
153+ Self :: options ( ) . read ( true ) . open ( path) . await
157154 }
158155
159156 /// Opens a file in write-only mode.
@@ -188,9 +185,12 @@ impl File {
188185 /// [`write_all`]: fn@crate::io::AsyncWriteExt::write_all
189186 /// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
190187 pub async fn create ( path : impl AsRef < Path > ) -> io:: Result < File > {
191- let path = path. as_ref ( ) . to_owned ( ) ;
192- let std_file = asyncify ( move || StdFile :: create ( path) ) . await ?;
193- Ok ( File :: from_std ( std_file) )
188+ Self :: options ( )
189+ . write ( true )
190+ . create ( true )
191+ . truncate ( true )
192+ . open ( path)
193+ . await
194194 }
195195
196196 /// Opens a file in read-write mode.
You can’t perform that action at this time.
0 commit comments