about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTshepang Lekhonkhobe <tshepang@gmail.com>2015-08-26 23:40:36 +0200
committerTshepang Lekhonkhobe <tshepang@gmail.com>2015-08-26 23:40:36 +0200
commitcf3d6b569c00c0092cb7af50381d3ef42687040a (patch)
tree025a64b485ec6b7bd5437f20aac2f1e8b7376b11
parent74728862339e156ecc10dd5a515f51bbaf9b4192 (diff)
downloadrust-cf3d6b569c00c0092cb7af50381d3ef42687040a.tar.gz
rust-cf3d6b569c00c0092cb7af50381d3ef42687040a.zip
doc: improve as_path example
-rw-r--r--src/libstd/path.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 71aed040871..6ec4b5c02a7 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -632,9 +632,11 @@ impl<'a> Components<'a> {
     /// ```
     /// use std::path::Path;
     ///
-    /// let path = Path::new("/tmp/foo/bar.txt");
+    /// let mut components = Path::new("/tmp/foo/bar.txt").components();
+    /// components.next();
+    /// components.next();
     ///
-    /// println!("{:?}", path.components().as_path());
+    /// assert_eq!(Path::new("foo/bar.txt"), components.as_path());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn as_path(&self) -> &'a Path {