• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::fs::asyncify;
2 
3 use std::io;
4 use std::path::Path;
5 
6 /// Renames a file or directory to a new name, replacing the original file if
7 /// `to` already exists.
8 ///
9 /// This will not work if the new name is on a different mount point.
10 ///
11 /// This is an async version of [`std::fs::rename`](std::fs::rename)
rename(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()>12 pub async fn rename(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
13     let from = from.as_ref().to_owned();
14     let to = to.as_ref().to_owned();
15 
16     asyncify(move || std::fs::rename(from, to)).await
17 }
18