Skip to content

Commit

Permalink
Fix deprecation warnings in bitstream writing
Browse files Browse the repository at this point in the history
  • Loading branch information
tuffy committed Aug 15, 2019
1 parent 558cf29 commit 29973ff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
name = "bitstream-io"
description = "Library for reading/writing un-aligned values from/to streams in big-endian and little-endian formats."
keywords = ["bitstream", "endian", "big-endian", "little-endian", "binary"]
version = "0.8.3"
version = "0.8.4"
authors = ["Brian Langenberger <[email protected]>"]
license = "MIT/Apache-2.0"
documentation = "https://docs.rs/bitstream-io/"
homepage = "https://github.com/tuffy/bitstream-io"
repository = "https://github.com/tuffy/bitstream-io"
edition = "2018"

[dependencies]
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
use std::fmt::Debug;
use std::io;
use std::marker::PhantomData;
use std::ops::{BitOrAssign, BitXor, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub};
use std::mem;
use std::ops::{BitOrAssign, BitXor, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub};

pub mod huffman;
pub mod read;
Expand Down
3 changes: 1 addition & 2 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@

use std::io;

use super::{BitQueue, Endianness, Numeric, SignedNumeric};
use huffman::ReadHuffmanTree;
use super::{huffman::ReadHuffmanTree, BitQueue, Endianness, Numeric, SignedNumeric};

/// For reading non-aligned bits from a stream of bytes in a given endianness.
///
Expand Down
11 changes: 5 additions & 6 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@

use std::io;

use super::{BitQueue, Endianness, Numeric, SignedNumeric};
use huffman::WriteHuffmanTree;
use super::{huffman::WriteHuffmanTree, BitQueue, Endianness, Numeric, SignedNumeric};

/// For writing bit values to an underlying stream in a given endianness.
///
Expand Down Expand Up @@ -361,13 +360,13 @@ impl<W: io::Write, E: Endianness> BitWriter<W, E> {
pub fn write_unary0(&mut self, value: u32) -> io::Result<()> {
match value {
0 => self.write_bit(false),
bits @ 1...31 => self
bits @ 1..=31 => self
.write(value, (1u32 << bits) - 1)
.and_then(|()| self.write_bit(false)),
32 => self
.write(value, 0xFFFF_FFFFu32)
.and_then(|()| self.write_bit(false)),
bits @ 32...63 => self
bits @ 32..=63 => self
.write(value, (1u64 << bits) - 1)
.and_then(|()| self.write_bit(false)),
64 => self
Expand Down Expand Up @@ -413,8 +412,8 @@ impl<W: io::Write, E: Endianness> BitWriter<W, E> {
pub fn write_unary1(&mut self, value: u32) -> io::Result<()> {
match value {
0 => self.write_bit(true),
1...32 => self.write(value, 0u32).and_then(|()| self.write_bit(true)),
33...64 => self.write(value, 0u64).and_then(|()| self.write_bit(true)),
1..=32 => self.write(value, 0u32).and_then(|()| self.write_bit(true)),
33..=64 => self.write(value, 0u64).and_then(|()| self.write_bit(true)),
mut bits => {
while bits > 64 {
self.write(64, 0u64)?;
Expand Down

0 comments on commit 29973ff

Please sign in to comment.