You can use the std::fs::rename() function to rename a file in Rust. Here's how you can do it for a csv file:
main.rs169 chars9 linesIn this example fs::rename() takes two arguments: old_name the existing name of the csv file, and new_name the desired new name for the file. The ? after fs::rename(old_name, new_name) is used for error handling.
Note that this will move the file to the same directory with the new name. If you want to keep the original file and create a new file with a different name, you can use fs::copy() to copy the file first and then rename the copied file.
gistlibby LogSnag