Skip to content

Commit 4f1bbc2

Browse files
committed
Rollup merge of rust-lang#24649 - nham:path_new_examples, r=steveklabnik
2 parents 83263b4 + ba4d55d commit 4f1bbc2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libstd/path.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,14 @@ impl Path {
12411241
///
12421242
/// Path::new("foo.txt");
12431243
/// ```
1244+
///
1245+
/// You can create `Path`s from `String`s, or even other `Path`s:
1246+
///
1247+
/// ```
1248+
/// let s = String::from("bar.txt");
1249+
/// let p = Path::new(&s);
1250+
/// Path::new(&p);
1251+
/// ```
12441252
#[stable(feature = "rust1", since = "1.0.0")]
12451253
pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &Path {
12461254
unsafe { mem::transmute(s.as_ref()) }

0 commit comments

Comments
 (0)