@@ -1420,6 +1420,9 @@ impl Clone for PathBuf {
14201420
14211421#[ stable( feature = "box_from_path" , since = "1.17.0" ) ]
14221422impl From < & Path > for Box < Path > {
1423+ /// Creates a boxed [`Path`] from a reference.
1424+ ///
1425+ /// This will allocate and clone `path` to it.
14231426 fn from ( path : & Path ) -> Box < Path > {
14241427 let boxed: Box < OsStr > = path. inner . into ( ) ;
14251428 let rw = Box :: into_raw ( boxed) as * mut Path ;
@@ -1429,6 +1432,9 @@ impl From<&Path> for Box<Path> {
14291432
14301433#[ stable( feature = "box_from_cow" , since = "1.45.0" ) ]
14311434impl From < Cow < ' _ , Path > > for Box < Path > {
1435+ /// Creates a boxed [`Path`] from a clone-on-write pointer.
1436+ ///
1437+ /// Converting from a `Cow::Owned` does not clone or allocate.
14321438 #[ inline]
14331439 fn from ( cow : Cow < ' _ , Path > ) -> Box < Path > {
14341440 match cow {
@@ -1471,6 +1477,9 @@ impl Clone for Box<Path> {
14711477
14721478#[ stable( feature = "rust1" , since = "1.0.0" ) ]
14731479impl < T : ?Sized + AsRef < OsStr > > From < & T > for PathBuf {
1480+ /// Converts a borrowed `OsStr` to a `PathBuf`.
1481+ ///
1482+ /// Allocates a [`PathBuf`] and copies the data into it.
14741483 #[ inline]
14751484 fn from ( s : & T ) -> PathBuf {
14761485 PathBuf :: from ( s. as_ref ( ) . to_os_string ( ) )
@@ -1575,6 +1584,10 @@ impl Default for PathBuf {
15751584
15761585#[ stable( feature = "cow_from_path" , since = "1.6.0" ) ]
15771586impl < ' a > From < & ' a Path > for Cow < ' a , Path > {
1587+ /// Creates a clone-on-write pointer from a reference to
1588+ /// [`Path`].
1589+ ///
1590+ /// This conversion does not clone or allocate.
15781591 #[ inline]
15791592 fn from ( s : & ' a Path ) -> Cow < ' a , Path > {
15801593 Cow :: Borrowed ( s)
@@ -1583,6 +1596,10 @@ impl<'a> From<&'a Path> for Cow<'a, Path> {
15831596
15841597#[ stable( feature = "cow_from_path" , since = "1.6.0" ) ]
15851598impl < ' a > From < PathBuf > for Cow < ' a , Path > {
1599+ /// Creates a clone-on-write pointer from an owned
1600+ /// instance of [`PathBuf`].
1601+ ///
1602+ /// This conversion does not clone or allocate.
15861603 #[ inline]
15871604 fn from ( s : PathBuf ) -> Cow < ' a , Path > {
15881605 Cow :: Owned ( s)
@@ -1591,6 +1608,10 @@ impl<'a> From<PathBuf> for Cow<'a, Path> {
15911608
15921609#[ stable( feature = "cow_from_pathbuf_ref" , since = "1.28.0" ) ]
15931610impl < ' a > From < & ' a PathBuf > for Cow < ' a , Path > {
1611+ /// Creates a clone-on-write pointer from a reference to
1612+ /// [`PathBuf`].
1613+ ///
1614+ /// This conversion does not clone or allocate.
15941615 #[ inline]
15951616 fn from ( p : & ' a PathBuf ) -> Cow < ' a , Path > {
15961617 Cow :: Borrowed ( p. as_path ( ) )
@@ -1599,6 +1620,9 @@ impl<'a> From<&'a PathBuf> for Cow<'a, Path> {
15991620
16001621#[ stable( feature = "pathbuf_from_cow_path" , since = "1.28.0" ) ]
16011622impl < ' a > From < Cow < ' a , Path > > for PathBuf {
1623+ /// Converts a clone-on-write pointer to an owned path.
1624+ ///
1625+ /// Converting from a `Cow::Owned` does not clone or allocate.
16021626 #[ inline]
16031627 fn from ( p : Cow < ' a , Path > ) -> Self {
16041628 p. into_owned ( )
@@ -2462,10 +2486,10 @@ impl Path {
24622486 /// Returns `true` if the path points at an existing entity.
24632487 ///
24642488 /// This function will traverse symbolic links to query information about the
2465- /// destination file. In case of broken symbolic links this will return `false`.
2489+ /// destination file.
24662490 ///
2467- /// If you cannot access the directory containing the file, e.g., because of a
2468- /// permission error, this will return `false`.
2491+ /// If you cannot access the metadata of the file, e.g. because of a
2492+ /// permission error or broken symbolic links , this will return `false`.
24692493 ///
24702494 /// # Examples
24712495 ///
@@ -2513,10 +2537,10 @@ impl Path {
25132537 /// Returns `true` if the path exists on disk and is pointing at a regular file.
25142538 ///
25152539 /// This function will traverse symbolic links to query information about the
2516- /// destination file. In case of broken symbolic links this will return `false`.
2540+ /// destination file.
25172541 ///
2518- /// If you cannot access the directory containing the file, e.g., because of a
2519- /// permission error, this will return `false`.
2542+ /// If you cannot access the metadata of the file, e.g. because of a
2543+ /// permission error or broken symbolic links , this will return `false`.
25202544 ///
25212545 /// # Examples
25222546 ///
@@ -2545,10 +2569,10 @@ impl Path {
25452569 /// Returns `true` if the path exists on disk and is pointing at a directory.
25462570 ///
25472571 /// This function will traverse symbolic links to query information about the
2548- /// destination file. In case of broken symbolic links this will return `false`.
2572+ /// destination file.
25492573 ///
2550- /// If you cannot access the directory containing the file, e.g., because of a
2551- /// permission error, this will return `false`.
2574+ /// If you cannot access the metadata of the file, e.g. because of a
2575+ /// permission error or broken symbolic links , this will return `false`.
25522576 ///
25532577 /// # Examples
25542578 ///
0 commit comments