@@ -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
}
@@ -1484,10 +1487,8 @@ impl Dir {
1484
1487
///
1485
1488
/// # Errors
1486
1489
///
1487
- /// This function will return an error in these (and other) situations:
1488
- /// * The path doesn't exist
1489
- /// * The path doesn't specify a directory
1490
- /// * The process doesn't have permission to read the directory
1490
+ /// This function will return an error if `path` does not point to an existing directory.
1491
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1491
1492
///
1492
1493
/// # Examples
1493
1494
///
@@ -1514,10 +1515,7 @@ impl Dir {
1514
1515
///
1515
1516
/// # Errors
1516
1517
///
1517
- /// This function will return an error in these (and other) situations:
1518
- /// * The path doesn't exist
1519
- /// * The path doesn't specify a directory
1520
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1518
+ /// This function may return an error according to [`OpenOptions::open`].
1521
1519
///
1522
1520
/// # Examples
1523
1521
///
@@ -1540,10 +1538,8 @@ impl Dir {
1540
1538
///
1541
1539
/// # Errors
1542
1540
///
1543
- /// This function will return an error in these (and other) situations:
1544
- /// * The path doesn't exist
1545
- /// * The path doesn't specify a regular file
1546
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1541
+ /// This function will return an error if `path` does not point to an existing file.
1542
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1547
1543
///
1548
1544
/// # Examples
1549
1545
///
@@ -1568,11 +1564,7 @@ impl Dir {
1568
1564
///
1569
1565
/// # Errors
1570
1566
///
1571
- /// This function may return an error in these (and other) situations, depending on the
1572
- /// specified `opts`:
1573
- /// * The path doesn't exist
1574
- /// * The path doesn't specify a regular file
1575
- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1567
+ /// This function may return an error according to [`OpenOptions::open`].
1576
1568
///
1577
1569
/// # Examples
1578
1570
///
@@ -1597,9 +1589,8 @@ impl Dir {
1597
1589
///
1598
1590
/// # Errors
1599
1591
///
1600
- /// This function will return an error in these (and other) situations:
1601
- /// * The path exists
1602
- /// * The process doesn't have permission to create the directory
1592
+ /// This function will return an error if `path` points to an existing file or directory.
1593
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1603
1594
///
1604
1595
/// # Examples
1605
1596
///
@@ -1624,10 +1615,8 @@ impl Dir {
1624
1615
///
1625
1616
/// # Errors
1626
1617
///
1627
- /// This function will return an error in these (and other) situations:
1628
- /// * The path doesn't exist
1629
- /// * The path doesn't specify a regular file
1630
- /// * The process doesn't have permission to delete the file.
1618
+ /// This function will return an error if `path` does not point to an existing file.
1619
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1631
1620
///
1632
1621
/// # Examples
1633
1622
///
@@ -1650,11 +1639,8 @@ impl Dir {
1650
1639
///
1651
1640
/// # Errors
1652
1641
///
1653
- /// This function will return an error in these (and other) situations:
1654
- /// * The path doesn't exist
1655
- /// * The path doesn't specify a directory
1656
- /// * The directory isn't empty
1657
- /// * The process doesn't have permission to delete the directory.
1642
+ /// This function will return an error if `path` does not point to an existing, non-empty directory.
1643
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1658
1644
///
1659
1645
/// # Examples
1660
1646
///
@@ -1678,10 +1664,8 @@ impl Dir {
1678
1664
///
1679
1665
/// # Errors
1680
1666
///
1681
- /// This function will return an error in these (and other) situations:
1682
- /// * The `from` path doesn't exist
1683
- /// * The `from` path doesn't specify a directory
1684
- /// * `self` and `to_dir` are on different mount points
1667
+ /// This function will return an error if `from` does not point to an existing file or directory.
1668
+ /// Other errors may also be returned according to [`OpenOptions::open`].
1685
1669
///
1686
1670
/// # Examples
1687
1671
///
0 commit comments