Skip to content

Commit

Permalink
Clarify that std::fs::rename can move
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Apr 30, 2015
1 parent 2f613bf commit 35f176b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,9 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {

/// 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
Expand All @@ -861,6 +864,17 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
/// # 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<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> {
fs_imp::rename(from.as_ref(), to.as_ref())
Expand Down

0 comments on commit 35f176b

Please sign in to comment.