pub fn try_remove_file(path: impl AsRef<Path>) -> Result<()>Expand description
Attempts to remove a file at the specified path, retrying up to 4 times on failure.
This function tries to delete the file located at the given path. If the removal fails (e.g., due to temporary filesystem locks or race conditions), it will retry up to four times before returning the final error.
§Parameters
path: The path to the file to be removed. Accepts any type implementingAsRef<Path>.
§Returns
- An
Resultindicating success or failure. ReturnsOk(())if the file is removed, or anErrif all attempts fail.
§Examples
use regd_testing;
regd_testing::io::try_remove_file("temp.txt").expect("failed to remove file");