mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Forbid uses of unwrap() in the code (#7795)
This commit is contained in:
@@ -233,7 +233,9 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive<u
|
||||
for decimals in min_decimals..max_decimals {
|
||||
let text = format!("{value:.decimals$}");
|
||||
let epsilon = 16.0 * f32::EPSILON; // margin large enough to handle most peoples round-tripping needs
|
||||
if almost_equal(text.parse::<f32>().unwrap(), value as f32, epsilon) {
|
||||
if let Ok(parsed_value) = text.parse::<f32>()
|
||||
&& almost_equal(parsed_value, value as f32, epsilon)
|
||||
{
|
||||
// Enough precision to show the value accurately - good!
|
||||
return text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user