Skip to content

Commit 0098408

Browse files
authored
address lints (#24)
1 parent 49026f5 commit 0098408

File tree

9 files changed

+16
-14
lines changed

9 files changed

+16
-14
lines changed

benches/sherlock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ fn round_trip(input: &[u8]) {
5858

5959
use criterion::{black_box, criterion_group, criterion_main, Criterion};
6060

61+
#[allow(clippy::missing_panics_doc)]
6162
pub fn criterion_benchmark(c: &mut Criterion) {
6263
let mut input_string = String::new();
6364
File::open("./resources/sherlock.txt")

examples/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ where
4444
}
4545

4646
#[allow(unused)]
47-
pub fn round_trip_string<M>(model: M, input: String)
47+
pub fn round_trip_string<M>(model: M, input: &str)
4848
where
4949
M: Model<Symbol = char> + Clone,
5050
{

examples/fenwick_adaptive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Model for StringModel {
6060

6161
fn update(&mut self, symbol: Option<&Self::Symbol>) {
6262
let fenwick_symbol = symbol.map(|c| self.alphabet.iter().position(|x| x == c).unwrap());
63-
self.fenwick_model.update(fenwick_symbol.as_ref())
63+
self.fenwick_model.update(fenwick_symbol.as_ref());
6464
}
6565
}
6666

@@ -73,5 +73,5 @@ fn main() {
7373
.read_to_string(&mut input)
7474
.unwrap();
7575

76-
common::round_trip_string(model, input);
76+
common::round_trip_string(model, &input);
7777
}

examples/fenwick_context_switching.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Model for StringModel {
5858

5959
fn update(&mut self, symbol: Option<&Self::Symbol>) {
6060
let fenwick_symbol = symbol.map(|c| self.alphabet.iter().position(|x| x == c).unwrap());
61-
self.fenwick_model.update(fenwick_symbol.as_ref())
61+
self.fenwick_model.update(fenwick_symbol.as_ref());
6262
}
6363
}
6464

@@ -71,5 +71,5 @@ fn main() {
7171
.read_to_string(&mut input)
7272
.unwrap();
7373

74-
common::round_trip_string(model, input);
74+
common::round_trip_string(model, &input);
7575
}

fenwick-model/src/simple.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct FenwickModel {
1313
panic_on_saturation: bool,
1414
}
1515

16+
#[must_use]
1617
pub struct Builder {
1718
model: FenwickModel,
1819
}
@@ -33,13 +34,13 @@ impl Builder {
3334
self
3435
}
3536

37+
#[must_use]
3638
pub fn build(self) -> FenwickModel {
3739
self.model
3840
}
3941
}
4042

4143
impl FenwickModel {
42-
#[must_use]
4344
pub fn builder(n_symbols: usize, max_denominator: u64) -> Builder {
4445
Builder::new(n_symbols, max_denominator)
4546
}

tests/common/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use arithmetic_coding::{Decoder, Encoder, Model};
22
use bitstream_io::{BigEndian, BitReader, BitWrite, BitWriter};
33

4-
pub fn round_trip<M>(model: M, input: Vec<M::Symbol>)
4+
pub fn round_trip<M>(model: M, input: &[M::Symbol])
55
where
66
M: Model + Clone,
77
M::Symbol: PartialEq + std::fmt::Debug + Clone,
88
{
9-
let buffer = encode(model.clone(), input.clone());
9+
let buffer = encode(model.clone(), input.to_owned());
1010
let output = decode(model, &buffer);
1111

12-
assert_eq!(input, output);
12+
assert_eq!(input, output.as_slice());
1313
}
1414

1515
fn encode<M>(model: M, input: Vec<M::Symbol>) -> Vec<u8>

tests/fixed_length.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl fixed_length::Model for MyModel {
4949

5050
#[test]
5151
fn round_trip() {
52-
let input = vec![Symbol::A, Symbol::B, Symbol::C];
52+
let input = &[Symbol::A, Symbol::B, Symbol::C];
5353

5454
common::round_trip(fixed_length::Wrapper::new(MyModel), input);
5555
}
@@ -58,7 +58,7 @@ fn round_trip() {
5858
#[should_panic]
5959
fn round_trip_fail() {
6060
// this is too many symbols for this model
61-
let input = vec![
61+
let input = &[
6262
Symbol::A,
6363
Symbol::B,
6464
Symbol::C,

tests/fuzz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ fn round_trip() {
88
let bytes: &[u8] = &[220, 255, 255];
99
let input: Vec<usize> = bytes.iter().copied().map(usize::from).collect();
1010

11-
common::round_trip(model, input);
11+
common::round_trip(model, &input);
1212
}

tests/sherlock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn round_trip() {
4444
let mut file = File::open("./resources/sherlock.txt").unwrap();
4545
let mut string = String::new();
4646
file.read_to_string(&mut string).unwrap();
47-
let input = string.chars().collect();
47+
let input: Vec<_> = string.chars().collect();
4848

49-
common::round_trip(StringModel, input);
49+
common::round_trip(StringModel, &input);
5050
}

0 commit comments

Comments
 (0)