Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ where
{
pub fn new(precision: u32) -> Self {
let low = B::ZERO;
let high = B::ONE << precision;
let high = (B::ONE << precision) - B::ONE;

Self {
precision,
Expand Down
6 changes: 3 additions & 3 deletions src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
/// Return an iterator over the decoded symbols.
///
/// The iterator will continue returning symbols until EOF is reached
pub const fn decode_all(&mut self) -> DecodeIter<M, R> {

Check warning on line 103 in src/decoder.rs

View workflow job for this annotation

GitHub Actions / lint

hiding a lifetime that's elided elsewhere is confusing

warning: hiding a lifetime that's elided elsewhere is confusing --> src/decoder.rs:103:29 | 103 | pub const fn decode_all(&mut self) -> DecodeIter<M, R> { | ^^^^^^^^^ ^^^^^^^^^^^^^^^^ the same lifetime is hidden here | | | the lifetime is elided here | = help: the same lifetime is referred to in inconsistent ways, making the signature confusing = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default help: use `'_` for type paths | 103 | pub const fn decode_all(&mut self) -> DecodeIter<'_, M, R> { | +++
DecodeIter { decoder: self }
}

Expand Down Expand Up @@ -209,13 +209,13 @@
fn normalise(&mut self) -> io::Result<()> {
while self.state.high < self.state.half() || self.state.low >= self.state.half() {
if self.state.high < self.state.half() {
self.state.high <<= 1;
self.state.high = (self.state.high << 1) + B::ONE;
self.state.low <<= 1;
self.x <<= 1;
} else {
// self.low >= self.half()
self.state.low = (self.state.low - self.state.half()) << 1;
self.state.high = (self.state.high - self.state.half()) << 1;
self.state.high = ((self.state.high - self.state.half()) << 1) + B::ONE;
self.x = (self.x - self.state.half()) << 1;
}

Expand All @@ -228,7 +228,7 @@
&& self.state.high < (self.state.three_quarter())
{
self.state.low = (self.state.low - self.state.quarter()) << 1;
self.state.high = (self.state.high - self.state.quarter()) << 1;
self.state.high = ((self.state.high - self.state.quarter()) << 1) + B::ONE;
self.x = (self.x - self.state.quarter()) << 1;

if self.input.next_bit()? == Some(true) {
Expand Down
6 changes: 3 additions & 3 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ where
while self.state.high < self.state.half() || self.state.low >= self.state.half() {
if self.state.high < self.state.half() {
self.emit(false)?;
self.state.high <<= 1;
self.state.high = (self.state.high << 1) + B::ONE;
self.state.low <<= 1;
} else {
self.emit(true)?;
self.state.low = (self.state.low - self.state.half()) << 1;
self.state.high = (self.state.high - self.state.half()) << 1;
self.state.high = ((self.state.high - self.state.half()) << 1) + B::ONE;
}
}

Expand All @@ -215,7 +215,7 @@ where
{
self.pending += 1;
self.state.low = (self.state.low - self.state.quarter()) << 1;
self.state.high = (self.state.high - self.state.quarter()) << 1;
self.state.high = ((self.state.high - self.state.quarter()) << 1) + B::ONE;
}

Ok(())
Expand Down
Loading