File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -968,14 +968,21 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
968968 fs_imp:: lstat ( path. as_ref ( ) ) . map ( Metadata )
969969}
970970
971- /// Rename a file or directory to a new name.
971+ /// Rename a file or directory to a new name, replacing the original file if
972+ /// `to` already exists.
972973///
973974/// This will not work if the new name is on a different mount point.
974975///
975976/// # Platform-specific behavior
976977///
977978/// This function currently corresponds to the `rename` function on Unix
978979/// and the `MoveFileEx` function with the `MOVEFILE_REPLACE_EXISTING` flag on Windows.
980+ ///
981+ /// Because of this, the behavior when both `from` and `to` exist differs. On
982+ /// Unix, if `from` is a directory, `to` must also be an (empty) directory. If
983+ /// `from` is not a directory, `to` must also be not a directory. In contrast,
984+ /// on Windows, `from` can be anything, but `to` must *not* be a directory.
985+ ///
979986/// Note that, this [may change in the future][changes].
980987/// [changes]: ../io/index.html#platform-specific-behavior
981988///
You can’t perform that action at this time.
0 commit comments