pub fn rename(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()>Available on crate feature
fs only.Expand description
Move a file or directory.
Unlike std::fs::rename, this will fallback to less efficient methods
of moving if the paths are on separate file systems. Currently, renaming
directories on separate filesystems is not supported to prevent unintended
behavior.
§If from is file
- will error if
tois a directory towill be replaced if exists
§If from is a directory
- will error if
toexists and is not a directory or is a non-empty directory (usecu::fs::rec_remove(to)to delete it first), or is on a different filesystem thanfrom.