fix: clarify that fs::rename on unix accepts targets that don't exist by sftse · Pull Request #149267 · rust-lang/rust (original) (raw)
The top of the paragraph already has the qualifier "when both from and to exist", so I think this is slightly redundant as written. This is a bit dense anyway so it wouldn't be bad to clean up the whole section. How about switching to a list format, something like:
This function currently corresponds to the rename function on Unix, and
MoveFileExW with a fallback to SetFileInformationByHandle on Windows.
The exact behavior differs:
- On Unix, when
fromis a directory andtoexists,tomust be an empty directory. - On Unix, when
fromis not a directory andtoexists,tomay not be a directory. - On Windows 10 version 1607 and above, the behavior is the same as Unix if the
filesystem supports
FileRenameInfoEx. - Otherwise on Windows,
fromcan be anything buttomust not be a directory. - If
todoes not exist,fromcan be anything.