@@ -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}
@@ -1500,10 +1503,8 @@ impl Dir {
15001503 ///
15011504 /// # Errors
15021505 ///
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`].
15071508 ///
15081509 /// # Examples
15091510 ///
@@ -1530,10 +1531,7 @@ impl Dir {
15301531 ///
15311532 /// # Errors
15321533 ///
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`].
15371535 ///
15381536 /// # Examples
15391537 ///
@@ -1556,10 +1554,8 @@ impl Dir {
15561554 ///
15571555 /// # Errors
15581556 ///
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`].
15631559 ///
15641560 /// # Examples
15651561 ///
@@ -1584,11 +1580,7 @@ impl Dir {
15841580 ///
15851581 /// # Errors
15861582 ///
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`].
15921584 ///
15931585 /// # Examples
15941586 ///
@@ -1613,9 +1605,8 @@ impl Dir {
16131605 ///
16141606 /// # Errors
16151607 ///
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`].
16191610 ///
16201611 /// # Examples
16211612 ///
@@ -1640,10 +1631,8 @@ impl Dir {
16401631 ///
16411632 /// # Errors
16421633 ///
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`].
16471636 ///
16481637 /// # Examples
16491638 ///
@@ -1666,11 +1655,8 @@ impl Dir {
16661655 ///
16671656 /// # Errors
16681657 ///
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`].
16741660 ///
16751661 /// # Examples
16761662 ///
@@ -1694,10 +1680,8 @@ impl Dir {
16941680 ///
16951681 /// # Errors
16961682 ///
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`].
17011685 ///
17021686 /// # Examples
17031687 ///
0 commit comments