@@ -40,7 +40,7 @@ pub trait FileExt {
40
40
///
41
41
/// # Examples
42
42
///
43
- /// ```
43
+ /// ```no_run
44
44
/// use std::io;
45
45
/// use std::fs::File;
46
46
/// use std::os::windows::prelude::*;
@@ -75,7 +75,7 @@ pub trait FileExt {
75
75
///
76
76
/// # Examples
77
77
///
78
- /// ```
78
+ /// ```no_run
79
79
/// use std::fs::File;
80
80
/// use std::os::windows::prelude::*;
81
81
///
@@ -120,10 +120,10 @@ pub trait OpenOptionsExt {
120
120
///
121
121
/// ```no_run
122
122
/// use std::fs::OpenOptions;
123
- /// use std::os::windows::fs::OpenOptionsExt ;
123
+ /// use std::os::windows::prelude::* ;
124
124
///
125
125
/// // Open without read and write permission, for example if you only need
126
- /// // to call `stat() ` on the file
126
+ /// // to call `stat` on the file
127
127
/// let file = OpenOptions::new().access_mode(0).open("foo.txt");
128
128
/// ```
129
129
///
@@ -145,13 +145,14 @@ pub trait OpenOptionsExt {
145
145
///
146
146
/// ```no_run
147
147
/// use std::fs::OpenOptions;
148
- /// use std::os::windows::fs::OpenOptionsExt ;
148
+ /// use std::os::windows::prelude::* ;
149
149
///
150
150
/// // Do not allow others to read or modify this file while we have it open
151
151
/// // for writing.
152
- /// let file = OpenOptions::new().write(true)
153
- /// .share_mode(0)
154
- /// .open("foo.txt");
152
+ /// let file = OpenOptions::new()
153
+ /// .write(true)
154
+ /// .share_mode(0)
155
+ /// .open("foo.txt");
155
156
/// ```
156
157
///
157
158
/// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx
@@ -170,13 +171,15 @@ pub trait OpenOptionsExt {
170
171
///
171
172
/// ```ignore
172
173
/// extern crate winapi;
174
+ ///
173
175
/// use std::fs::OpenOptions;
174
- /// use std::os::windows::fs::OpenOptionsExt ;
176
+ /// use std::os::windows::prelude::* ;
175
177
///
176
- /// let mut options = OpenOptions::new();
177
- /// options.create(true).write(true);
178
- /// options.custom_flags(winapi::FILE_FLAG_DELETE_ON_CLOSE);
179
- /// let file = options.open("foo.txt");
178
+ /// let file = OpenOptions::new()
179
+ /// .create(true)
180
+ /// .write(true)
181
+ /// .custom_flags(winapi::FILE_FLAG_DELETE_ON_CLOSE)
182
+ /// .open("foo.txt");
180
183
/// ```
181
184
///
182
185
/// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx
@@ -203,12 +206,15 @@ pub trait OpenOptionsExt {
203
206
///
204
207
/// ```ignore
205
208
/// extern crate winapi;
209
+ ///
206
210
/// use std::fs::OpenOptions;
207
- /// use std::os::windows::fs::OpenOptionsExt ;
211
+ /// use std::os::windows::prelude::* ;
208
212
///
209
- /// let file = OpenOptions::new().write(true).create(true)
210
- /// .attributes(winapi::FILE_ATTRIBUTE_HIDDEN)
211
- /// .open("foo.txt");
213
+ /// let file = OpenOptions::new()
214
+ /// .write(true)
215
+ /// .create(true)
216
+ /// .attributes(winapi::FILE_ATTRIBUTE_HIDDEN)
217
+ /// .open("foo.txt");
212
218
/// ```
213
219
///
214
220
/// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx
@@ -226,17 +232,18 @@ pub trait OpenOptionsExt {
226
232
///
227
233
/// # Examples
228
234
///
229
- /// ```ignore
235
+ /// ```no_run
230
236
/// use std::fs::OpenOptions;
231
- /// use std::os::windows::fs::OpenOptionsExt ;
237
+ /// use std::os::windows::prelude::* ;
232
238
///
233
- /// let options = OpenOptions::new();
234
- /// options.write(true).create(true);
239
+ /// let file = OpenOptions::new()
240
+ /// .write(true)
241
+ /// .create(true)
235
242
///
236
- /// // Sets the flag value to `SecurityIdentification`.
237
- /// options.security_qos_flags(1);
243
+ /// // Sets the flag value to `SecurityIdentification`.
244
+ /// options.security_qos_flags(1)
238
245
///
239
- /// let file = options .open("foo.txt");
246
+ /// .open("foo.txt");
240
247
/// ```
241
248
///
242
249
/// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx
@@ -289,15 +296,15 @@ pub trait MetadataExt {
289
296
///
290
297
/// # Examples
291
298
///
292
- /// ```ignore
299
+ /// ```no_run
293
300
/// use std::io;
294
- /// use std::io::prelude::*;
295
- /// use std::fs::File;
301
+ /// use std::fs;
296
302
/// use std::os::windows::prelude::*;
297
303
///
298
304
/// # fn foo() -> io::Result<()> {
299
- /// let mut file = File::open("foo.txt")?;
300
- /// let attributes = file.file_attributes();
305
+ /// let metadata = fs::metadata("foo.txt")?;
306
+ /// let attributes = metadata.file_attributes();
307
+ /// # Ok(())
301
308
/// # }
302
309
/// ```
303
310
///
@@ -319,15 +326,15 @@ pub trait MetadataExt {
319
326
///
320
327
/// # Examples
321
328
///
322
- /// ```ignore
329
+ /// ```no_run
323
330
/// use std::io;
324
- /// use std::io::prelude::*;
325
- /// use std::fs::File;
331
+ /// use std::fs;
326
332
/// use std::os::windows::prelude::*;
327
333
///
328
334
/// # fn foo() -> io::Result<()> {
329
- /// let mut file = File::open("foo.txt")?;
330
- /// let creation_time = file.creation_time();
335
+ /// let metadata = fs::metadata("foo.txt")?;
336
+ /// let creation_time = metadata.creation_time();
337
+ /// # Ok(())
331
338
/// # }
332
339
/// ```
333
340
///
@@ -354,15 +361,15 @@ pub trait MetadataExt {
354
361
///
355
362
/// # Examples
356
363
///
357
- /// ```ignore
364
+ /// ```no_run
358
365
/// use std::io;
359
- /// use std::io::prelude::*;
360
- /// use std::fs::File;
366
+ /// use std::fs;
361
367
/// use std::os::windows::prelude::*;
362
368
///
363
369
/// # fn foo() -> io::Result<()> {
364
- /// let mut file = File::open("foo.txt")?;
365
- /// let last_access_time = file.last_access_time();
370
+ /// let metadata = fs::metadata("foo.txt")?;
371
+ /// let last_access_time = metadata.last_access_time();
372
+ /// # Ok(())
366
373
/// # }
367
374
/// ```
368
375
///
@@ -387,15 +394,15 @@ pub trait MetadataExt {
387
394
///
388
395
/// # Examples
389
396
///
390
- /// ```ignore
397
+ /// ```no_run
391
398
/// use std::io;
392
- /// use std::io::prelude::*;
393
- /// use std::fs::File;
399
+ /// use std::fs;
394
400
/// use std::os::windows::prelude::*;
395
401
///
396
402
/// # fn foo() -> io::Result<()> {
397
- /// let mut file = File::open("foo.txt")?;
398
- /// let last_write_time = file.last_write_time();
403
+ /// let metadata = fs::metadata("foo.txt")?;
404
+ /// let last_write_time = metadata.last_write_time();
405
+ /// # Ok(())
399
406
/// # }
400
407
/// ```
401
408
///
@@ -410,15 +417,15 @@ pub trait MetadataExt {
410
417
///
411
418
/// # Examples
412
419
///
413
- /// ```ignore
420
+ /// ```no_run
414
421
/// use std::io;
415
- /// use std::io::prelude::*;
416
- /// use std::fs::File;
422
+ /// use std::fs;
417
423
/// use std::os::windows::prelude::*;
418
424
///
419
425
/// # fn foo() -> io::Result<()> {
420
- /// let mut file = File::open("foo.txt")?;
421
- /// let file_size = file.file_size();
426
+ /// let metadata = fs::metadata("foo.txt")?;
427
+ /// let file_size = metadata.file_size();
428
+ /// # Ok(())
422
429
/// # }
423
430
/// ```
424
431
#[ stable( feature = "metadata_ext" , since = "1.1.0" ) ]
@@ -441,7 +448,7 @@ impl MetadataExt for Metadata {
441
448
///
442
449
/// # Examples
443
450
///
444
- /// ```ignore
451
+ /// ```no_run
445
452
/// use std::os::windows::fs;
446
453
///
447
454
/// # fn foo() -> std::io::Result<()> {
@@ -462,7 +469,7 @@ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q)
462
469
///
463
470
/// # Examples
464
471
///
465
- /// ```ignore
472
+ /// ```no_run
466
473
/// use std::os::windows::fs;
467
474
///
468
475
/// # fn foo() -> std::io::Result<()> {
0 commit comments