Skip to content

Commit

Permalink
Refactor to avoid unreachable errors during wasm build
Browse files Browse the repository at this point in the history
  • Loading branch information
themkat committed Sep 1, 2024
1 parent 5ab1d59 commit 21d8d09
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,20 @@ impl Deserialize for crate::Texture2D {
#[allow(unused_variables)]
let bytes = raw_assets.get(&path)?;

#[cfg(not(feature = "image"))]
return Err(Error::FeatureMissing(extension));

if cfg!(feature = "svg") && "svg" == extension {
// to satisfy the compiler during wasm compile
#[cfg(not(feature = "svg"))]
return Err(Error::FeatureMissing("svg".to_string()));

#[cfg(feature = "svg")]
return img::deserialize_svg(path, bytes);
}
} else {
#[cfg(not(feature = "image"))]
return Err(Error::FeatureMissing(extension));

#[cfg(feature = "image")]
img::deserialize_img(path, bytes)
#[cfg(feature = "image")]
return img::deserialize_img(path, bytes);
}
}
}

Expand Down

0 comments on commit 21d8d09

Please sign in to comment.