about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2016-07-26 17:21:13 -0400
committerGitHub <noreply@github.com>2016-07-26 17:21:13 -0400
commit8de36f14233421fa3988b4b649dbdee75c76e3ec (patch)
treef8f7dc3062866a79bbb9c94b01645da67bb2f0d0
parent57d50299a7621d652fc668045d8f85e5703514d6 (diff)
parentdebb2ac76bd8b4ef8de0f470351a2b187afc91df (diff)
downloadrust-8de36f14233421fa3988b4b649dbdee75c76e3ec.tar.gz
rust-8de36f14233421fa3988b4b649dbdee75c76e3ec.zip
Rollup merge of #35010 - GuillaumeGomez:file_doc, r=steveklabnik
Improve Open doc

Part of #29356.

r? @steveklabnik
-rw-r--r--src/libstd/fs.rs28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index c1a48aea1ed..48753ccf1c3 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -173,12 +173,14 @@ pub struct DirBuilder {
 impl File {
     /// Attempts to open a file in read-only mode.
     ///
-    /// See the `OpenOptions::open` method for more details.
+    /// See the [`OpenOptions::open`] method for more details.
     ///
     /// # Errors
     ///
     /// This function will return an error if `path` does not already exist.
-    /// Other errors may also be returned according to `OpenOptions::open`.
+    /// Other errors may also be returned according to [`OpenOptions::open`].
+    ///
+    /// [`OpenOptions::open`]: struct.OpenOptions.html#method.open
     ///
     /// # Examples
     ///
@@ -200,7 +202,9 @@ impl File {
     /// This function will create a file if it does not exist,
     /// and will truncate it if it does.
     ///
-    /// See the `OpenOptions::open` function for more details.
+    /// See the [`OpenOptions::open`] function for more details.
+    ///
+    /// [`OpenOptions::open`]: struct.OpenOptions.html#method.open
     ///
     /// # Examples
     ///
@@ -241,7 +245,7 @@ impl File {
         self.inner.fsync()
     }
 
-    /// This function is similar to `sync_all`, except that it may not
+    /// This function is similar to [`sync_all`], except that it may not
     /// synchronize file metadata to the filesystem.
     ///
     /// This is intended for use cases that must synchronize content, but don't
@@ -249,7 +253,9 @@ impl File {
     /// operations.
     ///
     /// Note that some platforms may simply implement this in terms of
-    /// `sync_all`.
+    /// [`sync_all`].
+    ///
+    /// [`sync_all`]: struct.File.html#method.sync_all
     ///
     /// # Examples
     ///
@@ -321,6 +327,18 @@ impl File {
     /// The returned `File` is a reference to the same state that this object
     /// references. Both handles will read and write with the same cursor
     /// position.
+    ///
+    /// # Examples
+    ///
+    /// ```no_run
+    /// use std::fs::File;
+    ///
+    /// # fn foo() -> std::io::Result<()> {
+    /// let mut f = try!(File::open("foo.txt"));
+    /// let file_copy = try!(f.try_clone());
+    /// # Ok(())
+    /// # }
+    /// ```
     #[stable(feature = "file_try_clone", since = "1.9.0")]
     pub fn try_clone(&self) -> io::Result<File> {
         Ok(File {