about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-28 02:53:34 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-07-28 02:53:34 +0200
commit52c50ba276ffbdbe9c1a56e4f0b7d424f6bc22cc (patch)
tree3a3c5c5c6e5d66f9c1dc54dd81a96e40460e7b84 /src/libstd
parentf5d79521ae1bd53d90e820e9f8c78494fb3a102d (diff)
downloadrust-52c50ba276ffbdbe9c1a56e4f0b7d424f6bc22cc.tar.gz
rust-52c50ba276ffbdbe9c1a56e4f0b7d424f6bc22cc.zip
Add doc examples for std::fs::Metadata
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/fs.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index 48753ccf1c3..38fd93501a5 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -694,6 +694,23 @@ impl Metadata {
     ///
     /// This field may not be available on all platforms, and will return an
     /// `Err` on platforms where it is not available.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// # fn foo() -> std::io::Result<()> {
+    /// use std::fs;
+    ///
+    /// let metadata = try!(fs::metadata("foo.txt"));
+    ///
+    /// if let Ok(time) = metadata.modified() {
+    ///     println!("{:?}", time);
+    /// } else {
+    ///     println!("Not supported on this platform");
+    /// }
+    /// # Ok(())
+    /// # }
+    /// ```
     #[stable(feature = "fs_time", since = "1.10.0")]
     pub fn modified(&self) -> io::Result<SystemTime> {
         self.0.modified().map(FromInner::from_inner)
@@ -712,6 +729,23 @@ impl Metadata {
     ///
     /// This field may not be available on all platforms, and will return an
     /// `Err` on platforms where it is not available.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// # fn foo() -> std::io::Result<()> {
+    /// use std::fs;
+    ///
+    /// let metadata = try!(fs::metadata("foo.txt"));
+    ///
+    /// if let Ok(time) = metadata.accessed() {
+    ///     println!("{:?}", time);
+    /// } else {
+    ///     println!("Not supported on this platform");
+    /// }
+    /// # Ok(())
+    /// # }
+    /// ```
     #[stable(feature = "fs_time", since = "1.10.0")]
     pub fn accessed(&self) -> io::Result<SystemTime> {
         self.0.accessed().map(FromInner::from_inner)
@@ -726,6 +760,23 @@ impl Metadata {
     ///
     /// This field may not be available on all platforms, and will return an
     /// `Err` on platforms where it is not available.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// # fn foo() -> std::io::Result<()> {
+    /// use std::fs;
+    ///
+    /// let metadata = try!(fs::metadata("foo.txt"));
+    ///
+    /// if let Ok(time) = metadata.created() {
+    ///     println!("{:?}", time);
+    /// } else {
+    ///     println!("Not supported on this platform");
+    /// }
+    /// # Ok(())
+    /// # }
+    /// ```
     #[stable(feature = "fs_time", since = "1.10.0")]
     pub fn created(&self) -> io::Result<SystemTime> {
         self.0.created().map(FromInner::from_inner)