Rollup merge of #24649 - nham:path_new_examples, r=steveklabnik
This commit is contained in:
commit
4f1bbc209f
1 changed files with 8 additions and 0 deletions
|
|
@ -1241,6 +1241,14 @@ impl Path {
|
|||
///
|
||||
/// 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()) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue