Skip to content

Commit 94e35e9

Browse files
authored
tidy and update (#39)
1 parent 5b92738 commit 94e35e9

File tree

6 files changed

+26
-40
lines changed

6 files changed

+26
-40
lines changed

.clippy.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

arithmetic-coding-core/src/bitstore.rs

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,20 @@ pub trait BitStore:
2929
fn log2(self) -> u32;
3030
}
3131

32-
impl BitStore for u32 {
33-
const BITS: u32 = u32::BITS;
34-
const ONE: Self = 1;
35-
const ZERO: Self = 0;
36-
37-
fn log2(self) -> u32 {
38-
u32::ilog2(self)
39-
}
40-
}
41-
42-
impl BitStore for u64 {
43-
const BITS: u32 = u64::BITS as u32;
44-
const ONE: Self = 1;
45-
const ZERO: Self = 0;
46-
47-
fn log2(self) -> u32 {
48-
u64::ilog2(self)
49-
}
32+
macro_rules! impl_bitstore {
33+
($t:ty) => {
34+
impl BitStore for $t {
35+
const BITS: u32 = Self::BITS;
36+
const ONE: Self = 1;
37+
const ZERO: Self = 0;
38+
39+
fn log2(self) -> u32 {
40+
Self::ilog2(self)
41+
}
42+
}
43+
};
5044
}
5145

52-
impl BitStore for u128 {
53-
const BITS: u32 = u128::BITS as u32;
54-
const ONE: Self = 1;
55-
const ZERO: Self = 0;
56-
57-
fn log2(self) -> u32 {
58-
u128::ilog2(self)
59-
}
60-
}
46+
impl_bitstore! {u32}
47+
impl_bitstore! {u64}
48+
impl_bitstore! {u128}

arithmetic-coding-core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
clippy::cargo
88
)]
99
#![warn(clippy::pedantic)]
10-
#![feature(int_log)]
1110
#![feature(associated_type_defaults)]
1211

1312
mod bitstore;

examples/common/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ where
1616

1717
println!("\ndecoding...");
1818
for symbol in decode(model, &buffer) {
19-
println!("{:?}", symbol);
19+
println!("{symbol:?}");
2020
}
2121
}
2222

@@ -54,8 +54,8 @@ where
5454

5555
let output_bytes = buffer.len();
5656

57-
println!("input bytes: {}", input_bytes);
58-
println!("output bytes: {}", output_bytes);
57+
println!("input bytes: {input_bytes}");
58+
println!("output bytes: {output_bytes}");
5959

6060
println!(
6161
"compression ratio: {}",
@@ -67,5 +67,5 @@ where
6767
let mut prefix: String = output.into_iter().take(299).collect();
6868
prefix.push_str("...");
6969

70-
println!("{}", prefix);
70+
println!("{prefix}");
7171
}

examples/concatenated.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ fn main() {
9191
use symbolic::Symbol;
9292

9393
let input1 = [Symbol::A, Symbol::B, Symbol::C];
94-
println!("input1: {:?}", input1);
94+
println!("input1: {input1:?}");
9595

9696
let input2 = [2, 1, 1, 2, 2];
97-
println!("input2: {:?}", input2);
97+
println!("input2: {input2:?}");
9898

9999
println!("\nencoding...");
100100

@@ -106,10 +106,10 @@ fn main() {
106106
let (output1, output2) = decode2(symbolic::Model, integer::Model, &buffer);
107107

108108
for symbol in output1 {
109-
println!("{:?}", symbol);
109+
println!("{symbol:?}");
110110
}
111111
for symbol in output2 {
112-
println!("{:?}", symbol);
112+
println!("{symbol:?}");
113113
}
114114
}
115115

examples/sherlock.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ fn main() {
6060

6161
let output_bytes = buffer.len();
6262

63-
println!("input bytes: {}", input_bytes);
64-
println!("output bytes: {}", output_bytes);
63+
println!("input bytes: {input_bytes}");
64+
println!("output bytes: {output_bytes}");
6565

6666
println!(
6767
"compression ratio: {}",
@@ -75,5 +75,5 @@ fn main() {
7575
let mut prefix: String = output.into_iter().take(299).collect();
7676
prefix.push_str("...");
7777

78-
println!("{}", prefix);
78+
println!("{prefix}");
7979
}

0 commit comments

Comments
 (0)