From 3f871f08053b173344ada3fb51e4ed9da7f98d60 Mon Sep 17 00:00:00 2001 From: "minh.pham2000" Date: Tue, 7 Mar 2023 12:36:55 +0700 Subject: [PATCH] Add ArgIndex according to #4629 --- vm/src/function/number.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/vm/src/function/number.rs b/vm/src/function/number.rs index 5fa1e247e..b316aa5b8 100644 --- a/vm/src/function/number.rs +++ b/vm/src/function/number.rs @@ -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 for BigInt { +impl From 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 { Ok(Self { - value: obj.try_index(vm)?.as_bigint().clone(), + value: obj.try_index(vm)?, }) } }