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
{{ message }}
This repository was archived by the owner on Aug 20, 2021. It is now read-only.
Any reason why TempDir ignores errors when dropped?
I feel this is unsafe default behavior, as it could lead to a long-running process leaking temporary directories. To avoid this problem, a program must wrap TempDir and have the wrapper call TempDir::close in the wrapper's destructor—all to find out that an error occurred.
Here's an alternative. Suppose the TempDir destructor panicks on error instead of silently squashing it. This means a program's default behavior is to be notified of the error. If a program must prevent panicking—for whatever reason—then that program could do the wrapper thing and squash the error in the wrapper's destructor.
The alternative strategy is safer, as it requires action on the part of the programmer to ignore errors instead of requiring action on the part of the programmer to be notified of errors. In the case of TempDir's destructor, an error is probably a leak, the elimination of which is a big part of Rust's raison d'être.
The text was updated successfully, but these errors were encountered:
Any reason why
TempDir
ignores errors when dropped?I feel this is unsafe default behavior, as it could lead to a long-running process leaking temporary directories. To avoid this problem, a program must wrap
TempDir
and have the wrapper callTempDir::close
in the wrapper's destructor—all to find out that an error occurred.Here's an alternative. Suppose the
TempDir
destructor panicks on error instead of silently squashing it. This means a program's default behavior is to be notified of the error. If a program must prevent panicking—for whatever reason—then that program could do the wrapper thing and squash the error in the wrapper's destructor.The alternative strategy is safer, as it requires action on the part of the programmer to ignore errors instead of requiring action on the part of the programmer to be notified of errors. In the case of
TempDir
's destructor, an error is probably a leak, the elimination of which is a big part of Rust's raison d'être.The text was updated successfully, but these errors were encountered: