Skip to content

Commit 77f31af

Browse files
committed
Rewrite some range comparisons for readability
1 parent bb53f24 commit 77f31af

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/analysis.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const MAX_FFT_SIZE: usize = 32768;
3333

3434
// [spec] This MUST be a power of two in the range 32 to 32768, otherwise an
3535
// IndexSizeError exception MUST be thrown.
36+
#[allow(clippy::manual_range_contains)]
3637
fn assert_valid_fft_size(fft_size: usize) {
3738
assert!(
3839
fft_size.is_power_of_two(),
@@ -41,7 +42,7 @@ fn assert_valid_fft_size(fft_size: usize) {
4142
);
4243

4344
assert!(
44-
(MIN_FFT_SIZE..=MAX_FFT_SIZE).contains(&fft_size),
45+
fft_size >= MIN_FFT_SIZE && fft_size <= MAX_FFT_SIZE,
4546
"IndexSizeError - Invalid fft size: {:?} is outside range [{:?}, {:?}]",
4647
fft_size,
4748
MIN_FFT_SIZE,
@@ -51,9 +52,10 @@ fn assert_valid_fft_size(fft_size: usize) {
5152

5253
// [spec] If the value of this attribute is set to a value less than 0 or more
5354
// than 1, an IndexSizeError exception MUST be thrown.
55+
#[allow(clippy::manual_range_contains)]
5456
fn assert_valid_smoothing_time_constant(smoothing_time_constant: f64) {
5557
assert!(
56-
(0. ..=1.).contains(&smoothing_time_constant),
58+
smoothing_time_constant >= 0. && smoothing_time_constant <= 1.,
5759
"IndexSizeError - Invalid smoothing time constant: {:?} is outside range [0, 1]",
5860
smoothing_time_constant
5961
);

src/spatial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ pub fn azimuth_and_elevation(
256256
}
257257

258258
// Make azimuth relative to "forward" and not "right" listener vector.
259-
let max270 = std::ops::RangeInclusive::new(0., 270.);
260-
if max270.contains(&azimuth) {
259+
#[allow(clippy::manual_range_contains)]
260+
if azimuth >= 0. && azimuth <= 270. {
261261
azimuth = 90. - azimuth;
262262
} else {
263263
azimuth = 450. - azimuth;

0 commit comments

Comments
 (0)