summary refs log tree commit diff
path: root/src/libstd/path.rs
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-06-25 16:35:29 -0400
committerCorey Farwell <coreyf@rwell.org>2016-06-26 20:22:12 -0400
commitf1d600c6f8cbf7ab23f566e3912f1bebe892b0a6 (patch)
tree61a90f78b037d37d9ef5eaa8c37d154c12b471e2 /src/libstd/path.rs
parent35004b42bcd932222a4a58bf49d0d094ba397664 (diff)
downloadrust-f1d600c6f8cbf7ab23f566e3912f1bebe892b0a6.tar.gz
rust-f1d600c6f8cbf7ab23f566e3912f1bebe892b0a6.zip
Expand `std::path::Component` documentation.
Indicate how it gets created and add an example.
Diffstat (limited to 'src/libstd/path.rs')
-rw-r--r--src/libstd/path.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index f413bed86a8..e020945011a 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -525,6 +525,26 @@ impl<'a> Hash for PrefixComponent<'a> {
 ///
 /// See the module documentation for an in-depth explanation of components and
 /// their role in the API.
+///
+/// This `enum` is created from iterating over the [`path::Components`]
+/// `struct`.
+///
+/// # Examples
+///
+/// ```rust
+/// use std::path::{Component, Path};
+///
+/// let path = Path::new("/tmp/foo/bar.txt");
+/// let components = path.components().collect::<Vec<_>>();
+/// assert_eq!(&components, &[
+///     Component::RootDir,
+///     Component::Normal("tmp".as_ref()),
+///     Component::Normal("foo".as_ref()),
+///     Component::Normal("bar.txt".as_ref()),
+/// ]);
+/// ```
+///
+/// [`path::Components`]: struct.Components.html
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub enum Component<'a> {