@@ -132,7 +132,6 @@ pub enum TryLockError {
132
132
WouldBlock ,
133
133
}
134
134
135
- #[ unstable( feature = "dirfd" , issue = "120426" ) ]
136
135
/// An object providing access to a directory on the filesystem.
137
136
///
138
137
/// Files are automatically closed when they go out of scope. Errors detected
@@ -144,14 +143,18 @@ pub enum TryLockError {
144
143
///
145
144
/// ```no_run
146
145
/// #![feature(dirfd)]
147
- /// use std::fs::Dir;
146
+ /// use std::{ fs::Dir, io::Read} ;
148
147
///
149
148
/// fn main() -> std::io::Result<()> {
150
149
/// let dir = Dir::new("foo")?;
151
- /// let file = dir.open("bar.txt")?;
150
+ /// let mut file = dir.open("bar.txt")?;
151
+ /// let mut s = String::new();
152
+ /// file.read_to_string(&mut s)?;
153
+ /// println!("{}", s);
152
154
/// Ok(())
153
155
/// }
154
156
/// ```
157
+ #[ unstable( feature = "dirfd" , issue = "120426" ) ]
155
158
pub struct Dir {
156
159
inner : fs_imp:: Dir ,
157
160
}
@@ -1432,10 +1435,8 @@ impl Dir {
1432
1435
///
1433
1436
/// # Errors
1434
1437
///
1435
- /// This function will return an error in these (and other) situations:
1436
- /// * The path doesn't exist
1437
- /// * The path doesn't specify a directory
1438
- /// * The process doesn't have permission to read the directory
1438
+ /// This function will return an error if `path` does not point to an existing directory.
1439
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1439
1440
///
1440
1441
/// # Examples
1441
1442
///
@@ -1462,10 +1463,7 @@ impl Dir {
1462
1463
///
1463
1464
/// # Errors
1464
1465
///
1465
- /// This function will return an error in these (and other) situations:
1466
- /// * The path doesn't exist
1467
- /// * The path doesn't specify a directory
1468
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1466
+ /// This function may return an error according to [`OpenOptions::open`].
1469
1467
///
1470
1468
/// # Examples
1471
1469
///
@@ -1488,10 +1486,8 @@ impl Dir {
1488
1486
///
1489
1487
/// # Errors
1490
1488
///
1491
- /// This function will return an error in these (and other) situations:
1492
- /// * The path doesn't exist
1493
- /// * The path doesn't specify a regular file
1494
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1489
+ /// This function will return an error if `path` does not point to an existing file.
1490
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1495
1491
///
1496
1492
/// # Examples
1497
1493
///
@@ -1516,11 +1512,7 @@ impl Dir {
1516
1512
///
1517
1513
/// # Errors
1518
1514
///
1519
- /// This function may return an error in these (and other) situations, depending on the
1520
- /// specified `opts`:
1521
- /// * The path doesn't exist
1522
- /// * The path doesn't specify a regular file
1523
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1515
+ /// This function may return an error according to [`OpenOptions::open`].
1524
1516
///
1525
1517
/// # Examples
1526
1518
///
@@ -1545,9 +1537,8 @@ impl Dir {
1545
1537
///
1546
1538
/// # Errors
1547
1539
///
1548
- /// This function will return an error in these (and other) situations:
1549
- /// * The path exists
1550
- /// * The process doesn't have permission to create the directory
1540
+ /// This function will return an error if `path` points to an existing file or directory.
1541
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1551
1542
///
1552
1543
/// # Examples
1553
1544
///
@@ -1572,10 +1563,8 @@ impl Dir {
1572
1563
///
1573
1564
/// # Errors
1574
1565
///
1575
- /// This function will return an error in these (and other) situations:
1576
- /// * The path doesn't exist
1577
- /// * The path doesn't specify a regular file
1578
- /// * The process doesn't have permission to delete the file.
1566
+ /// This function will return an error if `path` does not point to an existing file.
1567
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1579
1568
///
1580
1569
/// # Examples
1581
1570
///
@@ -1598,11 +1587,8 @@ impl Dir {
1598
1587
///
1599
1588
/// # Errors
1600
1589
///
1601
- /// This function will return an error in these (and other) situations:
1602
- /// * The path doesn't exist
1603
- /// * The path doesn't specify a directory
1604
- /// * The directory isn't empty
1605
- /// * The process doesn't have permission to delete the directory.
1590
+ /// This function will return an error if `path` does not point to an existing, non-empty directory.
1591
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1606
1592
///
1607
1593
/// # Examples
1608
1594
///
@@ -1626,10 +1612,8 @@ impl Dir {
1626
1612
///
1627
1613
/// # Errors
1628
1614
///
1629
- /// This function will return an error in these (and other) situations:
1630
- /// * The `from` path doesn't exist
1631
- /// * The `from` path doesn't specify a directory
1632
- /// * `self` and `to_dir` are on different mount points
1615
+ /// This function will return an error if `from` does not point to an existing file or directory.
1616
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1633
1617
///
1634
1618
/// # Examples
1635
1619
///
0 commit comments