@@ -156,12 +156,14 @@ pub struct DirBuilder {
156
156
impl File {
157
157
/// Attempts to open a file in read-only mode.
158
158
///
159
- /// See the `OpenOptions::open` method for more details.
159
+ /// See the [ `OpenOptions::open`] method for more details.
160
160
///
161
161
/// # Errors
162
162
///
163
163
/// This function will return an error if `path` does not already exist.
164
- /// Other errors may also be returned according to `OpenOptions::open`.
164
+ /// Other errors may also be returned according to [`OpenOptions::open`].
165
+ ///
166
+ /// [`OpenOptions::open`]: struct.OpenOptions.html#method.open
165
167
///
166
168
/// # Examples
167
169
///
@@ -183,7 +185,9 @@ impl File {
183
185
/// This function will create a file if it does not exist,
184
186
/// and will truncate it if it does.
185
187
///
186
- /// See the `OpenOptions::open` function for more details.
188
+ /// See the [`OpenOptions::open`] function for more details.
189
+ ///
190
+ /// [`OpenOptions::open`]: struct.OpenOptions.html#method.open
187
191
///
188
192
/// # Examples
189
193
///
@@ -224,15 +228,17 @@ impl File {
224
228
self . inner . fsync ( )
225
229
}
226
230
227
- /// This function is similar to `sync_all`, except that it may not
231
+ /// This function is similar to [ `sync_all`] , except that it may not
228
232
/// synchronize file metadata to the filesystem.
229
233
///
230
234
/// This is intended for use cases that must synchronize content, but don't
231
235
/// need the metadata on disk. The goal of this method is to reduce disk
232
236
/// operations.
233
237
///
234
238
/// Note that some platforms may simply implement this in terms of
235
- /// `sync_all`.
239
+ /// [`sync_all`].
240
+ ///
241
+ /// [`sync_all`]: struct.File.html#method.sync_all
236
242
///
237
243
/// # Examples
238
244
///
@@ -304,6 +310,18 @@ impl File {
304
310
/// The returned `File` is a reference to the same state that this object
305
311
/// references. Both handles will read and write with the same cursor
306
312
/// position.
313
+ ///
314
+ /// # Examples
315
+ ///
316
+ /// ```no_run
317
+ /// use std::fs::File;
318
+ ///
319
+ /// # fn foo() -> std::io::Result<()> {
320
+ /// let mut f = try!(File::open("foo.txt"));
321
+ /// let file_copy = try!(f.try_clone());
322
+ /// # Ok(())
323
+ /// # }
324
+ /// ```
307
325
#[ stable( feature = "file_try_clone" , since = "1.9.0" ) ]
308
326
pub fn try_clone ( & self ) -> io:: Result < File > {
309
327
Ok ( File {
0 commit comments