Skip to content

Commit

Permalink
Rollup merge of #38141 - GuillaumeGomez:component_doc, r=frewsxcv
Browse files Browse the repository at this point in the history
Add Component examples

r? @frewsxcv
  • Loading branch information
frewsxcv authored Dec 3, 2016
2 parents 02ad965 + 60d1660 commit 2e038ed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2e038ed

Please sign in to comment.