We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f4b9cab commit a680354Copy full SHA for a680354
1 file changed
src/lib.rs
@@ -207,12 +207,17 @@ impl File {
207
}
208
209
210
-impl core::ops::Drop for File {
+impl Drop for File {
211
fn drop(&mut self) {
212
let api = get_api();
213
- // We could panic on error, but let's silently ignore it for now.
214
- // If you care, call `file.close()`.
+ // Don't close default (in, out, err) handles on drop because we can't
+ // re-open them.
215
+ if self.0.value() <= 2 {
216
+ // don't close
217
+ } else {
218
+ // close it
219
let _ = (api.close)(self.0);
220
+ }
221
222
223
0 commit comments