You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// When TempFile is dropped:
// 1. First, the File will be automatically closed (Drop for File)
// 2. Then our drop implementation will remove the file
impl Drop for TempFile {
fn drop(&mut self) {
// Note: File is already closed at this point
if let Err(e) = std::fs::remove_file(&self.path) {
I believe the comments are incorrect. I believe TempFile::drop is called before File::drop, so the file is still open when std::fs::remove_file is called.
As an additional issue, removing the file while it's still open is fine on Unix-like operating systems, but may cause problems on Windows or other operating systems that block removing opened files.