Skip to content

Commit 9577561

Browse files
Nick Hamannsteveklabnik
authored andcommitted
Add two examples for Path::new
1 parent 83b70c2 commit 9577561

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libstd/path.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,13 @@ impl Path {
12401240
/// use std::path::Path;
12411241
///
12421242
/// Path::new("foo.txt");
1243+
///
1244+
/// // Strings work too
1245+
/// let s = String::from("bar.txt");
1246+
/// let p = Path::new(&s);
1247+
///
1248+
/// // As do other Paths
1249+
/// Path::new(&p);
12431250
/// ```
12441251
#[stable(feature = "rust1", since = "1.0.0")]
12451252
pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &Path {

0 commit comments

Comments
 (0)