sdk/crypto/util.rs: replace ugly CtOption mess with cleaner version using .into() and match

This commit is contained in:
zero
2024-04-03 10:55:36 +02:00
parent b9cc42cdf4
commit d3404939aa

View File

@@ -107,11 +107,9 @@ pub trait FieldElemAsStr: PrimeField<Repr = [u8; 32]> {
let mut bytes = decode_hex_arr(hex)?;
bytes.reverse();
let value = Self::from_repr(bytes);
if value.is_some().into() {
Ok(value.unwrap())
} else {
Err(ContractError::HexFmtErr)
match Self::from_repr(bytes).into() {
Some(v) => Ok(v),
None => Err(ContractError::HexFmtErr),
}
}
}