@@ -153,7 +153,6 @@ pub enum TryLockError {
153153 WouldBlock ,
154154}
155155
156- #[ unstable( feature = "dirfd" , issue = "120426" ) ]
157156/// An object providing access to a directory on the filesystem.
158157///
159158/// Files are automatically closed when they go out of scope. Errors detected
@@ -165,14 +164,18 @@ pub enum TryLockError {
165164///
166165/// ```no_run
167166/// #![feature(dirfd)]
168- /// use std::fs::Dir;
167+ /// use std::{ fs::Dir, io::Read} ;
169168///
170169/// fn main() -> std::io::Result<()> {
171170/// 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);
173175/// Ok(())
174176/// }
175177/// ```
178+ #[ unstable( feature = "dirfd" , issue = "120426" ) ]
176179pub struct Dir {
177180 inner : fs_imp:: Dir ,
178181}
@@ -1505,10 +1508,8 @@ impl Dir {
15051508 ///
15061509 /// # Errors
15071510 ///
1508- /// This function will return an error in these (and other) situations:
1509- /// * The path doesn't exist
1510- /// * The path doesn't specify a directory
1511- /// * The process doesn't have permission to read the directory
1511+ /// This function will return an error if `path` does not point to an existing directory.
1512+ /// Other errors may also be returned according to [`OpenOptions::open`].
15121513 ///
15131514 /// # Examples
15141515 ///
@@ -1535,10 +1536,7 @@ impl Dir {
15351536 ///
15361537 /// # Errors
15371538 ///
1538- /// This function will return an error in these (and other) situations:
1539- /// * The path doesn't exist
1540- /// * The path doesn't specify a directory
1541- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1539+ /// This function may return an error according to [`OpenOptions::open`].
15421540 ///
15431541 /// # Examples
15441542 ///
@@ -1561,10 +1559,8 @@ impl Dir {
15611559 ///
15621560 /// # Errors
15631561 ///
1564- /// This function will return an error in these (and other) situations:
1565- /// * The path doesn't exist
1566- /// * The path doesn't specify a regular file
1567- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1562+ /// This function will return an error if `path` does not point to an existing file.
1563+ /// Other errors may also be returned according to [`OpenOptions::open`].
15681564 ///
15691565 /// # Examples
15701566 ///
@@ -1589,11 +1585,7 @@ impl Dir {
15891585 ///
15901586 /// # Errors
15911587 ///
1592- /// This function may return an error in these (and other) situations, depending on the
1593- /// specified `opts`:
1594- /// * The path doesn't exist
1595- /// * The path doesn't specify a regular file
1596- /// * The process doesn't have permission to read/write (according to `opts`) the directory
1588+ /// This function may return an error according to [`OpenOptions::open`].
15971589 ///
15981590 /// # Examples
15991591 ///
@@ -1618,9 +1610,8 @@ impl Dir {
16181610 ///
16191611 /// # Errors
16201612 ///
1621- /// This function will return an error in these (and other) situations:
1622- /// * The path exists
1623- /// * The process doesn't have permission to create the directory
1613+ /// This function will return an error if `path` points to an existing file or directory.
1614+ /// Other errors may also be returned according to [`OpenOptions::open`].
16241615 ///
16251616 /// # Examples
16261617 ///
@@ -1645,10 +1636,8 @@ impl Dir {
16451636 ///
16461637 /// # Errors
16471638 ///
1648- /// This function will return an error in these (and other) situations:
1649- /// * The path doesn't exist
1650- /// * The path doesn't specify a regular file
1651- /// * The process doesn't have permission to delete the file.
1639+ /// This function will return an error if `path` does not point to an existing file.
1640+ /// Other errors may also be returned according to [`OpenOptions::open`].
16521641 ///
16531642 /// # Examples
16541643 ///
@@ -1671,11 +1660,8 @@ impl Dir {
16711660 ///
16721661 /// # Errors
16731662 ///
1674- /// This function will return an error in these (and other) situations:
1675- /// * The path doesn't exist
1676- /// * The path doesn't specify a directory
1677- /// * The directory isn't empty
1678- /// * The process doesn't have permission to delete the directory.
1663+ /// This function will return an error if `path` does not point to an existing, non-empty directory.
1664+ /// Other errors may also be returned according to [`OpenOptions::open`].
16791665 ///
16801666 /// # Examples
16811667 ///
@@ -1699,10 +1685,8 @@ impl Dir {
16991685 ///
17001686 /// # Errors
17011687 ///
1702- /// This function will return an error in these (and other) situations:
1703- /// * The `from` path doesn't exist
1704- /// * The `from` path doesn't specify a directory
1705- /// * `self` and `to_dir` are on different mount points
1688+ /// This function will return an error if `from` does not point to an existing file or directory.
1689+ /// Other errors may also be returned according to [`OpenOptions::open`].
17061690 ///
17071691 /// # Examples
17081692 ///
0 commit comments