Skip to content

Commit

Permalink
rust: Improve reading scale
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhekhorn committed Aug 22, 2024
1 parent 96cc543 commit c9bb4ac
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/dekoder/src/eko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ impl TryFrom<&Yaml> for EvolutionPoint {
fn try_from(yml: &Yaml) -> Result<Self> {
// 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()
Expand Down

0 comments on commit c9bb4ac

Please sign in to comment.