Skip to content

Commit

Permalink
Borrow writer
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a committed Oct 14, 2023
1 parent b5d9050 commit c300f40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/impls/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ mod tests {

#[test]
fn test_writer() {
let out_buf = vec![];
let mut writer = Writer::new(out_buf);
let mut out_buf = vec![];
let mut writer = Writer::new(&mut out_buf);
true.to_writer(&mut writer, BitSize(1)).unwrap();
assert_eq!(vec![true], writer.rest());

Expand Down
8 changes: 4 additions & 4 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ const fn bits_of<T>() -> usize {
}

/// Container to use with `from_reader`
pub struct Writer<W: Write> {
pub(crate) inner: W,
pub struct Writer<'a, W: Write> {
pub(crate) inner: &'a mut W,
leftover: BitVec<u8, Msb0>,
/// Total bits written
pub bits_written: usize,
}

impl<W: Write> Writer<W> {
impl<'a, W: Write> Writer<'a, W> {
/// Create a new `Writer`
#[inline]
pub fn new(inner: W) -> Self {
pub fn new(inner: &'a mut W) -> Self {
Self {
inner,
leftover: BitVec::new(),
Expand Down

0 comments on commit c300f40

Please sign in to comment.