1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Forbid uses of unwrap() in the code (#7795)

This commit is contained in:
Emil Ernerfeldt
2025-12-19 20:34:18 +01:00
committed by GitHub
parent 646fea2133
commit 7fe58bbfd4
44 changed files with 120 additions and 64 deletions

View File

@@ -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;
}