Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbepop committed May 29, 2023
1 parent 19ab2e3 commit 4ed8067
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/wasmi/src/engine/const_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ impl TryFrom<usize> for ConstRef {
type Error = TranslationError;

fn try_from(index: usize) -> Result<Self, Self::Error> {
u32::try_from(index)
.map_err(|_| TranslationErrorInner::ConstRefOutOfBounds)
.map_err(TranslationError::new)
.map(Self)
match u32::try_from(index) {
Ok(index) => Ok(Self(index)),
Err(_) => Err(TranslationError::new(
TranslationErrorInner::ConstRefOutOfBounds,
)),
}
}
}

Expand Down

0 comments on commit 4ed8067

Please sign in to comment.