@@ -1397,13 +1397,17 @@ 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
+ /// This conversion does not allocate memory
1400
1402
fn from ( boxed : Box < Path > ) -> PathBuf {
1401
1403
boxed. into_path_buf ( )
1402
1404
}
1403
1405
}
1404
1406
1405
1407
#[ stable( feature = "box_from_path_buf" , since = "1.20.0" ) ]
1406
1408
impl From < PathBuf > for Box < Path > {
1409
+ /// Converts a `PathBuf` into a `Box<Path>`.
1410
+ /// This conversion does not allocate memory
1407
1411
fn from ( p : PathBuf ) -> Box < Path > {
1408
1412
p. into_boxed_path ( )
1409
1413
}
@@ -1426,20 +1430,28 @@ impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
1426
1430
1427
1431
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1428
1432
impl From < OsString > for PathBuf {
1433
+ /// Converts a `OsString` into a `PathBuf`.
1434
+ /// This conversion copies the data.
1435
+ /// This conversion does allocate memory.
1429
1436
fn from ( s : OsString ) -> PathBuf {
1430
1437
PathBuf { inner : s }
1431
1438
}
1432
1439
}
1433
1440
1434
1441
#[ stable( feature = "from_path_buf_for_os_string" , since = "1.14.0" ) ]
1435
1442
impl From < PathBuf > for OsString {
1443
+ /// Converts a `PathBuf` into a `OsString`.
1444
+ /// This conversion copies the data.
1445
+ /// This conversion does allocate memory.
1436
1446
fn from ( path_buf : PathBuf ) -> OsString {
1437
1447
path_buf. inner
1438
1448
}
1439
1449
}
1440
1450
1441
1451
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1442
1452
impl From < String > for PathBuf {
1453
+ /// Converts a `String` into a `PathBuf`.
1454
+ /// This conversion does not allocate memory
1443
1455
fn from ( s : String ) -> PathBuf {
1444
1456
PathBuf :: from ( OsString :: from ( s) )
1445
1457
}
@@ -1536,6 +1548,10 @@ impl<'a> From<Cow<'a, Path>> for PathBuf {
1536
1548
1537
1549
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
1538
1550
impl From < PathBuf > for Arc < Path > {
1551
+ /// Converts a `PathBuf` into a `Arc<Path>`.
1552
+ /// This conversion happens in place.
1553
+ /// This conversion does not allocate memory.
1554
+ /// This function is unsafe. Data can't be moved from this reference.
1539
1555
#[ inline]
1540
1556
fn from ( s : PathBuf ) -> Arc < Path > {
1541
1557
let arc: Arc < OsStr > = Arc :: from ( s. into_os_string ( ) ) ;
@@ -1545,6 +1561,10 @@ impl From<PathBuf> for Arc<Path> {
1545
1561
1546
1562
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
1547
1563
impl < ' a > From < & ' a Path > for Arc < Path > {
1564
+ /// Converts a `PathBuf` into a `Arc<Path>`.
1565
+ /// This conversion happens in place.
1566
+ /// This conversion does not allocate memory.
1567
+ /// This function is unsafe. Data can't be moved from this reference.
1548
1568
#[ inline]
1549
1569
fn from ( s : & Path ) -> Arc < Path > {
1550
1570
let arc: Arc < OsStr > = Arc :: from ( s. as_os_str ( ) ) ;
@@ -1554,6 +1574,10 @@ impl<'a> From<&'a Path> for Arc<Path> {
1554
1574
1555
1575
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
1556
1576
impl From < PathBuf > for Rc < Path > {
1577
+ /// Converts a `PathBuf` into a `Rc<Path>`.
1578
+ /// This conversion happens in place.
1579
+ /// This conversion does not allocate memory.
1580
+ /// This function is unsafe. Data can't be moved from this reference.
1557
1581
#[ inline]
1558
1582
fn from ( s : PathBuf ) -> Rc < Path > {
1559
1583
let rc: Rc < OsStr > = Rc :: from ( s. into_os_string ( ) ) ;
0 commit comments