diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-06-28 16:05:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-28 16:05:15 +0200 |
| commit | f8453a1d177d0cc7004f5ecac214746b0d349d82 (patch) | |
| tree | a60c20bce283fb8a83d411e841e48ec4ca9360e0 | |
| parent | b34f6e724542aff2424c4f0864a7eb4ca1062a6c (diff) | |
| parent | f1d600c6f8cbf7ab23f566e3912f1bebe892b0a6 (diff) | |
| download | rust-f8453a1d177d0cc7004f5ecac214746b0d349d82.tar.gz rust-f8453a1d177d0cc7004f5ecac214746b0d349d82.zip | |
Rollup merge of #34475 - frewsxcv:path-component, r=GuillaumeGomez
Expand `std::path::Component` documentation. Indicate how it gets created and add an example.
| -rw-r--r-- | src/libstd/path.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 8dc46239f3d..c103ff7f4b0 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> { |
