Don't panic in Drop.
The same behavior exists (without logging) in BufWriter from std crate. It's not recommended to depend on flush during drop. Instead user should flush explicitly and check for error.
This commit is contained in:
parent
4613196733
commit
de9977e571
@ -138,7 +138,10 @@ impl <'a, 'b> File<'a, 'b> {
|
||||
|
||||
impl<'a, 'b> Drop for File<'a, 'b> {
|
||||
fn drop(&mut self) {
|
||||
self.flush().expect("flush failed");
|
||||
match self.flush() {
|
||||
Err(err) => error!("flush failed {}", err),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,9 @@ impl<T: Read+Write+Seek> Seek for BufStream<T> {
|
||||
|
||||
impl<T: Read+Write+Seek> Drop for BufStream<T> {
|
||||
fn drop(&mut self) {
|
||||
self.flush().expect("flush failed!");
|
||||
match self.flush() {
|
||||
Err(err) => error!("flush failed {}", err),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user