usestd::path::PathBuf;/// RAII guard that deletes a temp file on drop unless [`persist`](Self::persist)
/// is called. Used by atomic-write save functions to ensure orphaned temp files
/// are cleaned up when a write failure causes an early return.
pubstructTempFileGuard{path: PathBuf,
}implTempFileGuard{pubfnnew(path: PathBuf)->Self{Self{ path }}/// Consume the guard without deleting the file. Call this after a
/// successful `fs::rename` to prevent cleanup on drop.
pubfnpersist(mutself){self.path =PathBuf::new();}}implDrop forTempFileGuard{fndrop(&mutself){if!self.path.as_os_str().is_empty(){let_=std::fs::remove_file(&self.path);}}}