Skip to content

Commit 3f871f0

Browse files
Add ArgIndex according to RustPython#4629
1 parent db7b945 commit 3f871f0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

vm/src/function/number.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::{AsObject, PyObjectRef, PyResult, TryFromObject, VirtualMachine};
2-
use num_bigint::BigInt;
1+
use crate::{builtins::PyIntRef, AsObject, PyObjectRef, PyResult, TryFromObject, VirtualMachine};
32
use num_complex::Complex64;
43
use std::ops::Deref;
54

@@ -128,20 +127,20 @@ impl TryFromObject for ArgIntoBool {
128127
}
129128

130129
// Implement ArgIndex to seperate between "true" int and int generated by index
131-
#[derive(Debug, PartialEq)]
130+
#[derive(Debug)]
132131
#[repr(transparent)]
133132
pub struct ArgIndex {
134-
value: BigInt,
133+
value: PyIntRef,
135134
}
136135

137-
impl From<ArgIndex> for BigInt {
136+
impl From<ArgIndex> for PyIntRef {
138137
fn from(arg: ArgIndex) -> Self {
139138
arg.value
140139
}
141140
}
142141

143142
impl Deref for ArgIndex {
144-
type Target = BigInt;
143+
type Target = PyIntRef;
145144

146145
fn deref(&self) -> &Self::Target {
147146
&self.value
@@ -151,7 +150,7 @@ impl Deref for ArgIndex {
151150
impl TryFromObject for ArgIndex {
152151
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
153152
Ok(Self {
154-
value: obj.try_index(vm)?.as_bigint().clone(),
153+
value: obj.try_index(vm)?,
155154
})
156155
}
157156
}

0 commit comments

Comments
 (0)