Skip to content

Commit

Permalink
Add trivial flush method to BitWriter
Browse files Browse the repository at this point in the history
Since it's specific to anything that implements Write,
it's attached to BitWriter rather than the BitWrite trait.
  • Loading branch information
tuffy committed Dec 17, 2020
1 parent 63ea00e commit 43bcb62
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ impl<W: io::Write, E: Endianness> BitWriter<W, E> {
pub fn into_unwritten(self) -> (u32, u8) {
(self.bitqueue.len(), self.bitqueue.value())
}

/// Flushes output stream to disk, if necessary.
/// Any partial bytes are not flushed.
///
/// # Errors
///
/// Passes along any errors from the underlying stream.
#[inline(always)]
pub fn flush(&mut self) -> io::Result<()> {
self.writer.flush()
}
}

/// A trait for anything that can write a variable number of
Expand Down

0 comments on commit 43bcb62

Please sign in to comment.