Function bitflags::__core::fs::rename
[−]
[src]
pub fn rename<P, Q>(from: P, to: Q) -> Result<(), Error> where Q: AsRef<Path>, P: AsRef<Path>
1.0.0Rename a file or directory to a new name.
This will not work if the new name is on a different mount point.
Platform-specific behavior
This function currently corresponds to the rename
function on Unix
and the MoveFileEx
function with the MOVEFILE_REPLACE_EXISTING
flag on Windows.
Note that, this may change in the future.
Errors
This function will return an error in the following situations, but is not limited to just these cases:
from
does not exist.- The user lacks permissions to view contents.
from
andto
are on separate filesystems.
Examples
use std::fs; try!(fs::rename("a.txt", "b.txt")); // Rename a.txt to b.txt