diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 2b15a4ff83ed1..6cc5d23c45f1f 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -844,6 +844,9 @@ pub fn symlink_metadata>(path: P) -> io::Result { /// Rename a file or directory to a new name. /// +/// Moving a file or directory is also a rename, in a sense, and so this +/// function is not limited a single directory. +/// /// # Errors /// /// This function will return an error if the provided `from` doesn't exist, if @@ -861,6 +864,17 @@ pub fn symlink_metadata>(path: P) -> io::Result { /// # Ok(()) /// # } /// ``` +/// +/// Moving: +/// +/// ``` +/// use std::fs; +/// +/// # fn foo() -> std::io::Result<()> { +/// try!(fs::rename("from/a.txt", "to/b.txt")); +/// # Ok(()) +/// # } +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn rename, Q: AsRef>(from: P, to: Q) -> io::Result<()> { fs_imp::rename(from.as_ref(), to.as_ref())