rustfile-move

Moving files from place to place in Rust


Say I have a file structure like so

a
|
+-- x
|
+-- y
b

and I wish to move x from a to b, what would be the best way of achieving this in Rust? I am working on Windows, but would optimally like to add cross platform support.

I am not particularly experienced with Rust at the moment, and haven't been able to find an answer on the web.

EDIT The cross platform support is unimportant at the moment :)


Solution

  • Use std::fs::rename() to move a file.