Implement Drop for FILE, so we flush when the process exits

This commit is contained in:
Tom Almeida
2018-07-03 10:05:12 +08:00
parent 81107f8cd1
commit 7277286efd
+9
View File
@@ -203,6 +203,15 @@ impl Read for FILE {
}
}
impl Drop for FILE {
fn drop(&mut self) {
// Flush
if let Some(_) = self.write {
self.write(&[]);
}
}
}
/// Clears EOF and ERR indicators on a stream
#[no_mangle]
pub extern "C" fn clearerr(stream: &mut FILE) {