mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Add ArgIndex according to #4629
This commit is contained in:
1 parent
db7b945262
commit
3f871f0805
1 file changed
+6
-7
@@ -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)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user