File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -150,10 +150,7 @@ impl File {
150
150
/// [`read_to_end`]: fn@crate::io::AsyncReadExt::read_to_end
151
151
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
152
152
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
157
154
}
158
155
159
156
/// Opens a file in write-only mode.
@@ -188,9 +185,7 @@ impl File {
188
185
/// [`write_all`]: fn@crate::io::AsyncWriteExt::write_all
189
186
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
190
187
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 ( ) . write ( true ) . create ( true ) . truncate ( true ) . open ( path) . await
194
189
}
195
190
196
191
/// Opens a file in read-write mode.
You can’t perform that action at this time.
0 commit comments