about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-12-03 15:39:54 -0500
committerGitHub <noreply@github.com>2016-12-03 15:39:54 -0500
commit2e038ed3deef5aea93a84d1e5a8fcff5eedf7631 (patch)
tree0dfd4a758a640a8b0af7925580d350ef73999794 /src/libstd
parent02ad965e3f8d83671348c3dbda93d4a0d1a13748 (diff)
parent60d1660748b30e2f3c69738e068d252271715268 (diff)
downloadrust-2e038ed3deef5aea93a84d1e5a8fcff5eedf7631.tar.gz
rust-2e038ed3deef5aea93a84d1e5a8fcff5eedf7631.zip
Rollup merge of #38141 - GuillaumeGomez:component_doc, r=frewsxcv
Add Component examples

r? @frewsxcv
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/path.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index d215f368d1e..d13baea40a9 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -457,7 +457,17 @@ pub enum Component<'a> {
 }
 
 impl<'a> Component<'a> {
-    /// Extracts the underlying `OsStr` slice
+    /// Extracts the underlying `OsStr` slice.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::path::Path;
+    ///
+    /// let path = Path::new("./tmp/foo/bar.txt");
+    /// let components: Vec<_> = path.components().map(|comp| comp.as_os_str()).collect();
+    /// assert_eq!(&components, &[".", "tmp", "foo", "bar.txt"]);
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn as_os_str(self) -> &'a OsStr {
         match self {