1
0
Fork 0
nih-plug/src/formatters.rs

9 lines
319 B
Rust
Raw Normal View History

//! Convenience functions for formatting and parsing parameter values in common formats.
use std::sync::Arc;
/// Round an `f32` value to always have a specific number of decimal digits.
2022-02-13 03:19:52 +11:00
pub fn f32_rounded(digits: usize) -> Arc<dyn Fn(f32) -> String + Send + Sync> {
Arc::new(move |x| format!("{:.digits$}", x))
}