improve parse_const check

This commit is contained in:
mos 2024-07-27 17:54:23 +02:00
parent 0ae1bdb3e7
commit 2c2d2da645
1 changed files with 4 additions and 6 deletions

View File

@ -77,13 +77,11 @@ impl<R: BufRead> Deserializer<R> {
}
fn parse_const(&mut self) -> Result<u64> {
let op = self.parse_op()?;
let bp::Op::Const(width, _float) = self.parse_op()? else {
return Err(Error::ExpectedConst);
};
if let bp::Op::Const(width, _float) = op {
Ok(self.read_uint((4 * (width + 1)) as usize)?)
} else {
Err(Error::ExpectedConst)
}
Ok(self.read_uint((4 * (width + 1)) as usize)?)
}
fn parse_data(&mut self) -> Result<u64> {