method File.rename
Renames or moves (atomic within one file system; an existing destination file is replaced).
Example:
use std.io { File, fs }
fn main() io {
let dir = fs.tempDir()!
File.writeText("{dir}/a", "1")!
File.rename("{dir}/a", "{dir}/b")!
print("{File.exists("{dir}/a")} {File.exists("{dir}/b")}")
fs.removeAll(dir)!
}Вывод
false true
pub(api) static fn rename(from: str, to: str) -> () | IoError ioС версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
from | str |
to | str |
Возвращает
()
Ошибки
IoError@error
Эффекты
io
Определено в: std/io/io.oxl:437