To delete a directory in Rust, you can use the std::fs::remove_dir function. It takes a path to the directory as an argument and returns a Result<(), std::io::Error>.
main.rs132 chars8 linesNote that the function will fail if the directory is not empty. To recursively delete a directory and all its content, you can use the std::fs::remove_dir_all function:
main.rs156 chars8 linesBoth functions return an std::io::Error if something goes wrong during the deletion, so it's important to handle the result properly.
gistlibby LogSnag