Add ArgIndex according to #4629

This commit is contained in:
minh.pham2000 committed 2023-03-07 12:36:55 +07:00
1 parent db7b945262
commit 3f871f0805
1 file changed
+6 -7
+6 -7
View File
@@ -1,5 +1,4 @@
use crate::{AsObject, PyObjectRef, PyResult, TryFromObject, VirtualMachine};
use num_bigint::BigInt;
use crate::{builtins::PyIntRef, AsObject, PyObjectRef, PyResult, TryFromObject, VirtualMachine};
use num_complex::Complex64;
use std::ops::Deref;
@@ -128,20 +127,20 @@ impl TryFromObject for ArgIntoBool {
}
// Implement ArgIndex to seperate between "true" int and int generated by index
#[derive(Debug, PartialEq)]
#[derive(Debug)]
#[repr(transparent)]
pub struct ArgIndex {
value: BigInt,
value: PyIntRef,
}
impl From<ArgIndex> for BigInt {
impl From<ArgIndex> for PyIntRef {
fn from(arg: ArgIndex) -> Self {
arg.value
}
}
impl Deref for ArgIndex {
type Target = BigInt;
type Target = PyIntRef;
fn deref(&self) -> &Self::Target {
&self.value
@@ -151,7 +150,7 @@ impl Deref for ArgIndex {
impl TryFromObject for ArgIndex {
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
Ok(Self {
value: obj.try_index(vm)?.as_bigint().clone(),
value: obj.try_index(vm)?,
})
}
}