]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/path.rs
Rollup merge of #24649 - nham:path_new_examples, r=steveklabnik
[rust.git] / src / libstd / path.rs
index e8052041aeb300a669eee29af47b3a74287fed9a..a52a3dbbef9a5f75956e914cd55e9cb7cce05147 100644 (file)
@@ -1241,6 +1241,14 @@ fn as_u8_slice(&self) -> &[u8] {
     ///
     /// Path::new("foo.txt");
     /// ```
+    ///
+    /// You can create `Path`s from `String`s, or even other `Path`s:
+    ///
+    /// ```
+    /// let s = String::from("bar.txt");
+    /// let p = Path::new(&s);
+    /// Path::new(&p);
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &Path {
         unsafe { mem::transmute(s.as_ref()) }