@@ -20,7 +20,9 @@ use sys;
2020use sys_common:: { FromInner , AsInner , AsInnerMut } ;
2121use sys:: platform:: fs:: MetadataExt as UnixMetadataExt ;
2222
23- /// Unix-specific extensions to `File`
23+ /// Unix-specific extensions to [`File`].
24+ ///
25+ /// [`File`]: ../../../../std/fs/struct.File.html
2426#[ stable( feature = "file_offset" , since = "1.15.0" ) ]
2527pub trait FileExt {
2628 /// Reads a number of bytes starting from a given offset.
@@ -269,19 +271,79 @@ impl MetadataExt for fs::Metadata {
269271 fn blocks ( & self ) -> u64 { self . st_blocks ( ) }
270272}
271273
272- /// Add special unix types (block/char device, fifo and socket)
274+ /// Add support for special unix types (block/char device, fifo and socket).
273275#[ stable( feature = "file_type_ext" , since = "1.5.0" ) ]
274276pub trait FileTypeExt {
275277 /// Returns whether this file type is a block device.
278+ ///
279+ /// # Examples
280+ ///
281+ /// ```
282+ /// use std::fs;
283+ /// use std::os::unix::fs::FileTypeExt;
284+ ///
285+ /// # use std::io;
286+ /// # fn f() -> io::Result<()> {
287+ /// let meta = fs::metadata("block_device_file")?;
288+ /// let file_type = meta.file_type();
289+ /// assert!(file_type.is_block_device());
290+ /// # Ok(())
291+ /// # }
292+ /// ```
276293 #[ stable( feature = "file_type_ext" , since = "1.5.0" ) ]
277294 fn is_block_device ( & self ) -> bool ;
278295 /// Returns whether this file type is a char device.
296+ ///
297+ /// # Examples
298+ ///
299+ /// ```
300+ /// use std::fs;
301+ /// use std::os::unix::fs::FileTypeExt;
302+ ///
303+ /// # use std::io;
304+ /// # fn f() -> io::Result<()> {
305+ /// let meta = fs::metadata("char_device_file")?;
306+ /// let file_type = meta.file_type();
307+ /// assert!(file_type.is_char_device());
308+ /// # Ok(())
309+ /// # }
310+ /// ```
279311 #[ stable( feature = "file_type_ext" , since = "1.5.0" ) ]
280312 fn is_char_device ( & self ) -> bool ;
281313 /// Returns whether this file type is a fifo.
314+ ///
315+ /// # Examples
316+ ///
317+ /// ```
318+ /// use std::fs;
319+ /// use std::os::unix::fs::FileTypeExt;
320+ ///
321+ /// # use std::io;
322+ /// # fn f() -> io::Result<()> {
323+ /// let meta = fs::metadata("fifo_file")?;
324+ /// let file_type = meta.file_type();
325+ /// assert!(file_type.is_fifo());
326+ /// # Ok(())
327+ /// # }
328+ /// ```
282329 #[ stable( feature = "file_type_ext" , since = "1.5.0" ) ]
283330 fn is_fifo ( & self ) -> bool ;
284331 /// Returns whether this file type is a socket.
332+ ///
333+ /// # Examples
334+ ///
335+ /// ```
336+ /// use std::fs;
337+ /// use std::os::unix::fs::FileTypeExt;
338+ ///
339+ /// # use std::io;
340+ /// # fn f() -> io::Result<()> {
341+ /// let meta = fs::metadata("unix.socket")?;
342+ /// let file_type = meta.file_type();
343+ /// assert!(file_type.is_socket());
344+ /// # Ok(())
345+ /// # }
346+ /// ```
285347 #[ stable( feature = "file_type_ext" , since = "1.5.0" ) ]
286348 fn is_socket ( & self ) -> bool ;
287349}
@@ -294,7 +356,9 @@ impl FileTypeExt for fs::FileType {
294356 fn is_socket ( & self ) -> bool { self . as_inner ( ) . is ( libc:: S_IFSOCK ) }
295357}
296358
297- /// Unix-specific extension methods for `fs::DirEntry`
359+ /// Unix-specific extension methods for [`fs::DirEntry`].
360+ ///
361+ /// [`fs::DirEntry`]: ../../../../std/fs/struct.DirEntry.html
298362#[ stable( feature = "dir_entry_ext" , since = "1.1.0" ) ]
299363pub trait DirEntryExt {
300364 /// Returns the underlying `d_ino` field in the contained `dirent`
@@ -354,7 +418,9 @@ pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>
354418}
355419
356420#[ stable( feature = "dir_builder" , since = "1.6.0" ) ]
357- /// An extension trait for `fs::DirBuilder` for unix-specific options.
421+ /// An extension trait for [`fs::DirBuilder`] for unix-specific options.
422+ ///
423+ /// [`fs::DirBuilder`]: ../../../../std/fs/struct.DirBuilder.html
358424pub trait DirBuilderExt {
359425 /// Sets the mode to create new directories with. This option defaults to
360426 /// 0o777.
0 commit comments