@@ -153,7 +153,6 @@ pub enum TryLockError {
153
153
WouldBlock ,
154
154
}
155
155
156
- #[ unstable( feature = "dirfd" , issue = "120426" ) ]
157
156
/// An object providing access to a directory on the filesystem.
158
157
///
159
158
/// Files are automatically closed when they go out of scope. Errors detected
@@ -165,14 +164,18 @@ pub enum TryLockError {
165
164
///
166
165
/// ```no_run
167
166
/// #![feature(dirfd)]
168
- /// use std::fs::Dir;
167
+ /// use std::{ fs::Dir, io::Read} ;
169
168
///
170
169
/// fn main() -> std::io::Result<()> {
171
170
/// let dir = Dir::new("foo")?;
172
- /// let file = dir.open("bar.txt")?;
171
+ /// let mut file = dir.open("bar.txt")?;
172
+ /// let mut s = String::new();
173
+ /// file.read_to_string(&mut s)?;
174
+ /// println!("{}", s);
173
175
/// Ok(())
174
176
/// }
175
177
/// ```
178
+ #[ unstable( feature = "dirfd" , issue = "120426" ) ]
176
179
pub struct Dir {
177
180
inner : fs_imp:: Dir ,
178
181
}
@@ -1500,10 +1503,8 @@ impl Dir {
1500
1503
///
1501
1504
/// # Errors
1502
1505
///
1503
- /// This function will return an error in these (and other) situations:
1504
- /// * The path doesn't exist
1505
- /// * The path doesn't specify a directory
1506
- /// * The process doesn't have permission to read the directory
1506
+ /// This function will return an error if `path` does not point to an existing directory.
1507
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1507
1508
///
1508
1509
/// # Examples
1509
1510
///
@@ -1530,10 +1531,7 @@ impl Dir {
1530
1531
///
1531
1532
/// # Errors
1532
1533
///
1533
- /// This function will return an error in these (and other) situations:
1534
- /// * The path doesn't exist
1535
- /// * The path doesn't specify a directory
1536
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1534
+ /// This function may return an error according to [`OpenOptions::open`].
1537
1535
///
1538
1536
/// # Examples
1539
1537
///
@@ -1556,10 +1554,8 @@ impl Dir {
1556
1554
///
1557
1555
/// # Errors
1558
1556
///
1559
- /// This function will return an error in these (and other) situations:
1560
- /// * The path doesn't exist
1561
- /// * The path doesn't specify a regular file
1562
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1557
+ /// This function will return an error if `path` does not point to an existing file.
1558
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1563
1559
///
1564
1560
/// # Examples
1565
1561
///
@@ -1584,11 +1580,7 @@ impl Dir {
1584
1580
///
1585
1581
/// # Errors
1586
1582
///
1587
- /// This function may return an error in these (and other) situations, depending on the
1588
- /// specified `opts`:
1589
- /// * The path doesn't exist
1590
- /// * The path doesn't specify a regular file
1591
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1583
+ /// This function may return an error according to [`OpenOptions::open`].
1592
1584
///
1593
1585
/// # Examples
1594
1586
///
@@ -1613,9 +1605,8 @@ impl Dir {
1613
1605
///
1614
1606
/// # Errors
1615
1607
///
1616
- /// This function will return an error in these (and other) situations:
1617
- /// * The path exists
1618
- /// * The process doesn't have permission to create the directory
1608
+ /// This function will return an error if `path` points to an existing file or directory.
1609
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1619
1610
///
1620
1611
/// # Examples
1621
1612
///
@@ -1640,10 +1631,8 @@ impl Dir {
1640
1631
///
1641
1632
/// # Errors
1642
1633
///
1643
- /// This function will return an error in these (and other) situations:
1644
- /// * The path doesn't exist
1645
- /// * The path doesn't specify a regular file
1646
- /// * The process doesn't have permission to delete the file.
1634
+ /// This function will return an error if `path` does not point to an existing file.
1635
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1647
1636
///
1648
1637
/// # Examples
1649
1638
///
@@ -1666,11 +1655,8 @@ impl Dir {
1666
1655
///
1667
1656
/// # Errors
1668
1657
///
1669
- /// This function will return an error in these (and other) situations:
1670
- /// * The path doesn't exist
1671
- /// * The path doesn't specify a directory
1672
- /// * The directory isn't empty
1673
- /// * The process doesn't have permission to delete the directory.
1658
+ /// This function will return an error if `path` does not point to an existing, non-empty directory.
1659
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1674
1660
///
1675
1661
/// # Examples
1676
1662
///
@@ -1694,10 +1680,8 @@ impl Dir {
1694
1680
///
1695
1681
/// # Errors
1696
1682
///
1697
- /// This function will return an error in these (and other) situations:
1698
- /// * The `from` path doesn't exist
1699
- /// * The `from` path doesn't specify a directory
1700
- /// * `self` and `to_dir` are on different mount points
1683
+ /// This function will return an error if `from` does not point to an existing file or directory.
1684
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1701
1685
///
1702
1686
/// # Examples
1703
1687
///
0 commit comments