Fix -inf parsing in s2v_f32_gain_to_db()
I noticed this thanks to a test I implemented myself in clap-validator ha.
This commit is contained in:
parent
27acce3237
commit
26422ae8e3
1 changed files with 2 additions and 1 deletions
|
@ -89,7 +89,8 @@ pub fn v2s_f32_gain_to_db(digits: usize) -> Arc<dyn Fn(f32) -> String + Send + S
|
|||
pub fn s2v_f32_gain_to_db() -> Arc<dyn Fn(&str) -> Option<f32> + Send + Sync> {
|
||||
Arc::new(|string| {
|
||||
let string = string.trim_end_matches(&[' ', 'd', 'D', 'b', 'B', 'f', 'F', 's', 'S']);
|
||||
if string.eq_ignore_ascii_case("-inf") {
|
||||
// NOTE: The above line strips the `f`, so checked for `-inf` here will always return false
|
||||
if string.eq_ignore_ascii_case("-in") {
|
||||
Some(0.0)
|
||||
} else {
|
||||
string.parse().ok().map(util::db_to_gain)
|
||||
|
|
Loading…
Add table
Reference in a new issue