Skip to content

Commit 2ac335d

Browse files
committed
Fix clippy
1 parent 222e518 commit 2ac335d

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/node/panner.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ use super::{
1515
AudioNode, ChannelConfig, ChannelConfigOptions, ChannelCountMode, ChannelInterpretation,
1616
};
1717

18+
/// Assert that the given value number is a valid value for coneOuterGain
19+
///
20+
/// # Panics
21+
///
22+
/// This function will panic if:
23+
/// - the given value is not finite and lower than zero
24+
#[track_caller]
25+
#[inline(always)]
26+
#[allow(clippy::manual_range_contains)]
27+
pub(crate) fn assert_valid_cone_outer_gain(value: f64) {
28+
assert!(
29+
value >= 0. && value <= 1.,
30+
"InvalidStateError - coneOuterGain must be in the range [0, 1]"
31+
);
32+
}
33+
1834
/// Load the HRTF processor for the given sample_rate
1935
///
2036
/// The included data contains the impulse responses at 44100 Hertz, so it needs to be resampled
@@ -405,10 +421,7 @@ impl PannerNode {
405421
rolloff_factor >= 0.,
406422
"RangeError - rolloffFactor cannot be negative"
407423
);
408-
assert!(
409-
cone_outer_gain >= 0. && cone_outer_gain <= 1.,
410-
"InvalidStateError - coneOuterGain must be in the range [0, 1]"
411-
);
424+
assert_valid_cone_outer_gain(cone_outer_gain);
412425
assert_valid_channel_count(channel_config.count);
413426
assert_valid_channel_count_mode(channel_config.count_mode);
414427

@@ -610,12 +623,8 @@ impl PannerNode {
610623
/// # Panics
611624
///
612625
/// Panics if the provided value is not in the range [0, 1]
613-
#[allow(clippy::manual_range_contains)]
614626
pub fn set_cone_outer_gain(&mut self, value: f64) {
615-
assert!(
616-
value >= 0. && value <= 1.,
617-
"InvalidStateError - coneOuterGain must be in the range [0, 1]"
618-
);
627+
assert_valid_cone_outer_gain(value);
619628
self.cone_outer_gain = value;
620629
self.registration
621630
.post_message(ControlMessage::ConeOuterGain(value));

0 commit comments

Comments
 (0)