Skip to content

Commit

Permalink
Ignore error of flush in Drop of CodedOutputStream
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed Feb 25, 2024
1 parent b14c8bd commit c1c937b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions protobuf/src/coded_output_stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,8 +1010,9 @@ impl<'a> Write for CodedOutputStream<'a> {

impl<'a> Drop for CodedOutputStream<'a> {
fn drop(&mut self) {
// This may panic
CodedOutputStream::flush(self).expect("failed to flush");
// User must call `flush` to guarantee that the data is written.
// Rust should have a lint to enforce `flush` call before drop.
let _ignore = CodedOutputStream::flush(self);
}
}

Expand Down

0 comments on commit c1c937b

Please sign in to comment.