diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-07-24 16:52:28 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-07-24 16:52:28 +0200 |
| commit | 16699635bc467b0940c11675dd73e7e444088c4e (patch) | |
| tree | cf7487d64feb022463f0bbb532763e9bd1934d8f /src/libstd/sys | |
| parent | dad29a6d03429874ddf5ce6f53045bae2e0d6fac (diff) | |
| download | rust-16699635bc467b0940c11675dd73e7e444088c4e.tar.gz rust-16699635bc467b0940c11675dd73e7e444088c4e.zip | |
Add DirEntry doc examples
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/ext/fs.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index bb90a977433..17c093e6cac 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -196,6 +196,22 @@ impl FileTypeExt for fs::FileType { pub trait DirEntryExt { /// Returns the underlying `d_ino` field in the contained `dirent` /// structure. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::unix::fs::DirEntryExt; + /// + /// if let Ok(entries) = fs::read_dir(".") { + /// for entry in entries { + /// if let Ok(entry) = entry { + /// // Here, `entry` is a `DirEntry`. + /// println!("{:?}: {}", entry.file_name(), entry.ino()); + /// } + /// } + /// } + /// ``` #[stable(feature = "dir_entry_ext", since = "1.1.0")] fn ino(&self) -> u64; } |
