From c9bb4ac04dd283deb98c166930402393466a2493 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Thu, 22 Aug 2024 12:38:38 +0300 Subject: [PATCH] rust: Improve reading scale --- crates/dekoder/src/eko.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/dekoder/src/eko.rs b/crates/dekoder/src/eko.rs index 1e950ac8a..1df9d7811 100644 --- a/crates/dekoder/src/eko.rs +++ b/crates/dekoder/src/eko.rs @@ -27,14 +27,11 @@ impl TryFrom<&Yaml> for EvolutionPoint { fn try_from(yml: &Yaml) -> Result { // work around float representation let scale = yml["scale"].as_f64(); - let scale = if scale.is_some() { - scale.ok_or(EKOError::KeyError( - "because failed to read scale as float".to_owned(), - ))? - } else { - yml["scale"].as_i64().ok_or(EKOError::KeyError( + let scale = match scale { + Some(scale) => scale, + None => yml["scale"].as_i64().ok_or(EKOError::KeyError( "because failed to read scale as float from int".to_owned(), - ))? as f64 + ))? as f64, }; let nf = yml["nf"] .as_i64()