diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-04-04 15:08:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-04 15:08:59 +0200 |
| commit | 886456deab17dd8cb49c4ade7dfcb0cc036b024b (patch) | |
| tree | 5d7bfb5e6ce516bc6be12ba7e472fff38592ed91 /src/libstd | |
| parent | e43f99ce576152d4b2f7315d491c4210211228d6 (diff) | |
| parent | a969d409874f91e197a1cd336a368f02d8a3ce47 (diff) | |
| download | rust-886456deab17dd8cb49c4ade7dfcb0cc036b024b.tar.gz rust-886456deab17dd8cb49c4ade7dfcb0cc036b024b.zip | |
Rollup merge of #59470 - czipperz:document-fs-file-close, r=dtolnay
Document std::fs::File close behavior ignoring errors Resolves #52685
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/fs.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 705dc8f40b5..90369f9771f 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -21,7 +21,9 @@ use crate::time::SystemTime; /// it was opened with. Files also implement [`Seek`] to alter the logical cursor /// that the file contains internally. /// -/// Files are automatically closed when they go out of scope. +/// Files are automatically closed when they go out of scope. Errors detected +/// on closing are ignored by the implementation of `Drop`. Use the method +/// [`sync_all`] if these errors must be manually handled. /// /// # Examples /// @@ -84,6 +86,7 @@ use crate::time::SystemTime; /// [`Read`]: ../io/trait.Read.html /// [`Write`]: ../io/trait.Write.html /// [`BufReader<R>`]: ../io/struct.BufReader.html +/// [`sync_all`]: struct.File.html#method.sync_all #[stable(feature = "rust1", since = "1.0.0")] pub struct File { inner: fs_imp::File, @@ -391,9 +394,13 @@ impl File { /// Attempts to sync all OS-internal metadata to disk. /// - /// This function will attempt to ensure that all in-core data reaches the + /// This function will attempt to ensure that all in-memory data reaches the /// filesystem before returning. /// + /// This can be used to handle errors that would otherwise only be caught + /// when the `File` is closed. Dropping a file will ignore errors in + /// synchronizing this in-memory data. + /// /// # Examples /// /// ```no_run |
