@@ -173,12 +173,14 @@ pub struct DirBuilder {
173
173
impl File {
174
174
/// Attempts to open a file in read-only mode.
175
175
///
176
- /// See the `OpenOptions::open` method for more details.
176
+ /// See the [ `OpenOptions::open`] method for more details.
177
177
///
178
178
/// # Errors
179
179
///
180
180
/// This function will return an error if `path` does not already exist.
181
- /// Other errors may also be returned according to `OpenOptions::open`.
181
+ /// Other errors may also be returned according to [`OpenOptions::open`].
182
+ ///
183
+ /// [`OpenOptions::open`]: struct.OpenOptions.html#method.open
182
184
///
183
185
/// # Examples
184
186
///
@@ -200,7 +202,9 @@ impl File {
200
202
/// This function will create a file if it does not exist,
201
203
/// and will truncate it if it does.
202
204
///
203
- /// See the `OpenOptions::open` function for more details.
205
+ /// See the [`OpenOptions::open`] function for more details.
206
+ ///
207
+ /// [`OpenOptions::open`]: struct.OpenOptions.html#method.open
204
208
///
205
209
/// # Examples
206
210
///
@@ -241,15 +245,17 @@ impl File {
241
245
self . inner . fsync ( )
242
246
}
243
247
244
- /// This function is similar to `sync_all`, except that it may not
248
+ /// This function is similar to [ `sync_all`] , except that it may not
245
249
/// synchronize file metadata to the filesystem.
246
250
///
247
251
/// This is intended for use cases that must synchronize content, but don't
248
252
/// need the metadata on disk. The goal of this method is to reduce disk
249
253
/// operations.
250
254
///
251
255
/// Note that some platforms may simply implement this in terms of
252
- /// `sync_all`.
256
+ /// [`sync_all`].
257
+ ///
258
+ /// [`sync_all`]: struct.File.html#method.sync_all
253
259
///
254
260
/// # Examples
255
261
///
@@ -321,6 +327,18 @@ impl File {
321
327
/// The returned `File` is a reference to the same state that this object
322
328
/// references. Both handles will read and write with the same cursor
323
329
/// position.
330
+ ///
331
+ /// # Examples
332
+ ///
333
+ /// ```no_run
334
+ /// use std::fs::File;
335
+ ///
336
+ /// # fn foo() -> std::io::Result<()> {
337
+ /// let mut f = try!(File::open("foo.txt"));
338
+ /// let file_copy = try!(f.try_clone());
339
+ /// # Ok(())
340
+ /// # }
341
+ /// ```
324
342
#[ stable( feature = "file_try_clone" , since = "1.9.0" ) ]
325
343
pub fn try_clone ( & self ) -> io:: Result < File > {
326
344
Ok ( File {
0 commit comments