@@ -132,7 +132,6 @@ pub enum TryLockError {
132132 WouldBlock ,
133133}
134134
135- #[ unstable( feature = "dirfd" , issue = "120426" ) ]
136135/// An object providing access to a directory on the filesystem.
137136///
138137/// Files are automatically closed when they go out of scope. Errors detected
@@ -144,14 +143,18 @@ pub enum TryLockError {
144143///
145144/// ```no_run
146145/// #![feature(dirfd)]
147- /// use std::fs::Dir;
146+ /// use std::{ fs::Dir, io::Read} ;
148147///
149148/// fn main() -> std::io::Result<()> {
150149/// 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);
152154/// Ok(())
153155/// }
154156/// ```
157+ #[ unstable( feature = "dirfd" , issue = "120426" ) ]
155158pub struct Dir {
156159 inner : fs_imp:: Dir ,
157160}
@@ -1484,10 +1487,8 @@ impl Dir {
14841487 ///
14851488 /// # Errors
14861489 ///
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`].
14911492 ///
14921493 /// # Examples
14931494 ///
@@ -1514,10 +1515,7 @@ impl Dir {
15141515 ///
15151516 /// # Errors
15161517 ///
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`].
15211519 ///
15221520 /// # Examples
15231521 ///
@@ -1540,10 +1538,8 @@ impl Dir {
15401538 ///
15411539 /// # Errors
15421540 ///
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`].
15471543 ///
15481544 /// # Examples
15491545 ///
@@ -1568,11 +1564,7 @@ impl Dir {
15681564 ///
15691565 /// # Errors
15701566 ///
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`].
15761568 ///
15771569 /// # Examples
15781570 ///
@@ -1597,9 +1589,8 @@ impl Dir {
15971589 ///
15981590 /// # Errors
15991591 ///
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`].
16031594 ///
16041595 /// # Examples
16051596 ///
@@ -1624,10 +1615,8 @@ impl Dir {
16241615 ///
16251616 /// # Errors
16261617 ///
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`].
16311620 ///
16321621 /// # Examples
16331622 ///
@@ -1650,11 +1639,8 @@ impl Dir {
16501639 ///
16511640 /// # Errors
16521641 ///
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`].
16581644 ///
16591645 /// # Examples
16601646 ///
@@ -1678,10 +1664,8 @@ impl Dir {
16781664 ///
16791665 /// # Errors
16801666 ///
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`].
16851669 ///
16861670 /// # Examples
16871671 ///
0 commit comments