Skip to content

Commit

Permalink
Rollup merge of rust-lang#34475 - frewsxcv:path-component, r=Guillaum…
Browse files Browse the repository at this point in the history
…eGomez

Expand `std::path::Component` documentation.

Indicate how it gets created and add an example.
  • Loading branch information
GuillaumeGomez committed Jun 28, 2016
2 parents b34f6e7 + f1d600c commit f8453a1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit f8453a1

Please sign in to comment.