use to_index instead of to_index_opt in int special_retrieve

This commit is contained in:
Robert Booth
2021-04-26 09:48:54 +09:00
parent 48d7c360b6
commit dd50b252a8
2 changed files with 4 additions and 4 deletions

View File

@@ -79,8 +79,8 @@ impl PyValue for PyInt {
vm.ctx.new_int(self.value)
}
fn special_retrieve(vm: &VirtualMachine, obj: PyObjectRef) -> Option<PyResult<PyRef<Self>>> {
vm.to_index_opt(obj)
fn special_retrieve(vm: &VirtualMachine, obj: &PyObjectRef) -> Option<PyResult<PyRef<Self>>> {
Some(vm.to_index(obj))
}
}

View File

@@ -390,7 +390,7 @@ where
obj.downcast()
.map_err(|obj| pyref_payload_error(vm, class, obj))
} else {
T::special_retrieve(vm, obj.clone())
T::special_retrieve(vm, &obj)
.unwrap_or_else(|| Err(pyref_type_error(vm, class, obj)))
}
}
@@ -928,7 +928,7 @@ pub trait PyValue: fmt::Debug + PyThreadingConstraint + Sized + 'static {
}
#[inline(always)]
fn special_retrieve(vm: &VirtualMachine, obj: PyObjectRef) -> Option<PyResult<PyRef<Self>>> {
fn special_retrieve(vm: &VirtualMachine, obj: &PyObjectRef) -> Option<PyResult<PyRef<Self>>> {
let _ = vm;
let _ = obj;
None