Skip to content

Commit

Permalink
clippy: treewide fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phip1611 committed Apr 28, 2024
1 parent 0ed0f9f commit 8065651
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ jobs:
- name: rustfmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy --all-targets
run: cargo clippy --all-targets --all-features
- name: Rustdoc
run: cargo doc --no-deps --document-private-items
run: cargo doc --no-deps --document-private-items --all-features
10 changes: 5 additions & 5 deletions src/audio_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ mod tests {
let mut hist = AudioHistory::new(2.0);
assert_eq!(hist.total_consumed_samples, 0);

hist.update([0.0].iter().copied());
hist.update(core::iter::once(0.0));
assert_eq!(hist.total_consumed_samples, 1);
assert_eq!(hist.passed_time(), Duration::from_secs_f32(0.5));

Expand Down Expand Up @@ -357,12 +357,12 @@ mod tests {
fn sample_info() {
let mut hist = AudioHistory::new(1.0);

hist.update([0.0].iter().copied());
hist.update(core::iter::once(0.0));
assert_eq!(
hist.index_to_sample_info(0).duration_behind,
Duration::from_secs(0)
);
hist.update([0.0].iter().copied());
hist.update(core::iter::once(0.0));
assert_eq!(
hist.index_to_sample_info(0).duration_behind,
Duration::from_secs(1)
Expand Down Expand Up @@ -430,11 +430,11 @@ mod tests {
let mut history = AudioHistory::new(1.0);
for i in 0..history.data().capacity() {
assert_eq!(history.total_index_to_index(i), None);
history.update([0.0].iter().copied());
history.update(core::iter::once(0.0));
assert_eq!(history.total_index_to_index(i), Some(i));
}

history.update([0.0].iter().copied());
history.update(core::iter::once(0.0));
// No longer existing.
assert_eq!(history.total_index_to_index(0), None);
assert_eq!(history.total_index_to_index(1), Some(0));
Expand Down
7 changes: 4 additions & 3 deletions src/beat_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ impl BeatDetector {
}

#[cfg(test)]
#[allow(clippy::excessive_precision)]
#[allow(clippy::missing_const_for_fn)]
mod tests {
use super::*;
use crate::{test_utils, SampleInfo};
Expand Down Expand Up @@ -218,7 +220,7 @@ mod tests {
let _ = detector.update_and_detect_beat(input);
assert_eq!(detector.history.data().len(), 3);

let input = AudioInput::<_>::Iterator([0.3].iter().copied());
let input = AudioInput::<_>::Iterator(core::iter::once(0.3));
let _ = detector.update_and_detect_beat(input);
assert_eq!(detector.history.data().len(), 4);

Expand Down Expand Up @@ -297,13 +299,12 @@ mod tests {
) -> Vec<usize> {
samples
.chunks(chunk_size)
.map(|samples| {
.flat_map(|samples| {
let input = AudioInput::<StubIterator>::SliceMono(samples);
detector
.update_and_detect_beat(input)
.map(|info| info.max.total_index)
})
.filter_map(|info| info)
.collect::<std::vec::Vec<_>>()
}

Expand Down

0 comments on commit 8065651

Please sign in to comment.