rust: Checking for report life with PathBuf to verify distinctive filenames


PathBuf shall we us take a look at to peer if a report
exists ahead of writing to it, so we will be able to
profit from that to be sure that
we do not overwrite a report that already
exists, although the consumer has indicated
a name that might overwrite any other report.

let mut i: usize = 0;
loop { let dest_filename = layout!( "{}{}", filename, if i == 0 { "".to_string() } else { i.to_string() } ); let mut dest = garden_path.sign up for(dest_filename); dest.set_extension("md"); if dest.exists() { i = i + 1; } else { fs::rename(garden_tmpfile, &dest)?; spoil; }