@@ -1397,13 +1397,20 @@ impl<'a> From<&'a Path> for Box<Path> {
1397
1397
1398
1398
#[ stable( feature = "path_buf_from_box" , since = "1.18.0" ) ]
1399
1399
impl From < Box < Path > > for PathBuf {
1400
+ /// Converts a `Box<Path>` into a `PathBuf`
1401
+ ///
1402
+ /// This conversion does not allocate or copy memory.
1400
1403
fn from ( boxed : Box < Path > ) -> PathBuf {
1401
1404
boxed. into_path_buf ( )
1402
1405
}
1403
1406
}
1404
1407
1405
1408
#[ stable( feature = "box_from_path_buf" , since = "1.20.0" ) ]
1406
1409
impl From < PathBuf > for Box < Path > {
1410
+ /// Converts a `PathBuf` into a `Box<Path>`
1411
+ ///
1412
+ /// This conversion currently should not allocate memory,
1413
+ /// but this behavior is not guaranteed on all platforms or in all future versions.
1407
1414
fn from ( p : PathBuf ) -> Box < Path > {
1408
1415
p. into_boxed_path ( )
1409
1416
}
@@ -1426,20 +1433,29 @@ impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
1426
1433
1427
1434
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1428
1435
impl From < OsString > for PathBuf {
1436
+ /// Converts a `OsString` into a `PathBuf`
1437
+ ///
1438
+ /// This conversion does not allocate or copy memory.
1429
1439
fn from ( s : OsString ) -> PathBuf {
1430
1440
PathBuf { inner : s }
1431
1441
}
1432
1442
}
1433
1443
1434
1444
#[ stable( feature = "from_path_buf_for_os_string" , since = "1.14.0" ) ]
1435
1445
impl From < PathBuf > for OsString {
1446
+ /// Converts a `PathBuf` into a `OsString`
1447
+ ///
1448
+ /// This conversion does not allocate or copy memory.
1436
1449
fn from ( path_buf : PathBuf ) -> OsString {
1437
1450
path_buf. inner
1438
1451
}
1439
1452
}
1440
1453
1441
1454
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1442
1455
impl From < String > for PathBuf {
1456
+ /// Converts a `String` into a `PathBuf`
1457
+ ///
1458
+ /// This conversion does not allocate or copy memory.
1443
1459
fn from ( s : String ) -> PathBuf {
1444
1460
PathBuf :: from ( OsString :: from ( s) )
1445
1461
}
@@ -1536,6 +1552,7 @@ impl<'a> From<Cow<'a, Path>> for PathBuf {
1536
1552
1537
1553
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
1538
1554
impl From < PathBuf > for Arc < Path > {
1555
+ /// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
1539
1556
#[ inline]
1540
1557
fn from ( s : PathBuf ) -> Arc < Path > {
1541
1558
let arc: Arc < OsStr > = Arc :: from ( s. into_os_string ( ) ) ;
@@ -1545,6 +1562,7 @@ impl From<PathBuf> for Arc<Path> {
1545
1562
1546
1563
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
1547
1564
impl < ' a > From < & ' a Path > for Arc < Path > {
1565
+ /// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
1548
1566
#[ inline]
1549
1567
fn from ( s : & Path ) -> Arc < Path > {
1550
1568
let arc: Arc < OsStr > = Arc :: from ( s. as_os_str ( ) ) ;
@@ -1554,6 +1572,7 @@ impl<'a> From<&'a Path> for Arc<Path> {
1554
1572
1555
1573
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
1556
1574
impl From < PathBuf > for Rc < Path > {
1575
+ /// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
1557
1576
#[ inline]
1558
1577
fn from ( s : PathBuf ) -> Rc < Path > {
1559
1578
let rc: Rc < OsStr > = Rc :: from ( s. into_os_string ( ) ) ;
@@ -1563,6 +1582,7 @@ impl From<PathBuf> for Rc<Path> {
1563
1582
1564
1583
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
1565
1584
impl < ' a > From < & ' a Path > for Rc < Path > {
1585
+ /// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
1566
1586
#[ inline]
1567
1587
fn from ( s : & Path ) -> Rc < Path > {
1568
1588
let rc: Rc < OsStr > = Rc :: from ( s. as_os_str ( ) ) ;
0 commit comments