pub fn replace_file(from: &Path, to: &Path) -> Result<()>
Renames from over to. On Windows a sharing violation is retried briefly; elsewhere this is a plain rename, which is already atomic.
from
to