fix: Do not unwrap() in require_int
(cherry picked from commit c7d2e3e02a977424634ee12015265906e18039a0)
This commit is contained in:
parent
22ffd20c53
commit
c775792b63
1 changed files with 2 additions and 1 deletions
|
|
@ -135,6 +135,7 @@ impl EvalState {
|
|||
}
|
||||
pub fn value_type_unforced(&self, value: &Value) -> Option<ValueType> {
|
||||
let r = unsafe { raw::get_type(self.context.ptr(), value.raw_ptr()) };
|
||||
// .unwrap(): no reason for this to fail, as it does not evaluate
|
||||
self.context.check_err().unwrap();
|
||||
ValueType::from_raw(r)
|
||||
}
|
||||
|
|
@ -153,7 +154,7 @@ impl EvalState {
|
|||
}
|
||||
}
|
||||
pub fn require_int(&self, v: &Value) -> Result<Int> {
|
||||
let t = self.value_type(v).unwrap();
|
||||
let t = self.value_type(v)?;
|
||||
if t != ValueType::Int {
|
||||
bail!("expected an int, but got a {:?}", t);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue