Skip to content

Commit d975858

Browse files
committed
PyObjectRc derefs to PyObject instead of PyRc
1 parent 125b409 commit d975858

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

vm/src/pyobject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::obj::objstaticmethod::PyStaticMethod;
3535
use crate::obj::objstr;
3636
use crate::obj::objtuple::{PyTuple, PyTupleRef};
3737
use crate::obj::objtype::{self, PyClass, PyClassRef};
38-
pub use crate::pyobjectrc::PyObjectRc;
38+
pub use crate::pyobjectrc::{PyObjectRc, PyObjectWeak};
3939
use crate::scope::Scope;
4040
use crate::slots::{PyClassSlots, PyTpFlags};
4141
use crate::types::{create_type, create_type_with_slots, initialize_types, TypeZoo};

vm/src/pyobjectrc.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ impl<T> Deref for PyObjectRc<T>
6666
where
6767
T: ?Sized + PyObjectPayload,
6868
{
69-
type Target = PyRc<PyObject<T>>;
69+
type Target = PyObject<T>;
7070

7171
#[inline]
72-
fn deref(&self) -> &PyRc<PyObject<T>> {
73-
&self.inner
72+
fn deref(&self) -> &PyObject<T> {
73+
self.inner.deref()
7474
}
7575
}
7676

@@ -125,16 +125,6 @@ where
125125
}
126126
}
127127

128-
impl<T> borrow::Borrow<PyRc<PyObject<T>>> for PyObjectRc<T>
129-
where
130-
T: ?Sized + PyObjectPayload,
131-
PyRc<PyObject<T>>: borrow::Borrow<PyRc<PyObject<T>>>,
132-
{
133-
fn borrow(&self) -> &PyRc<PyObject<T>> {
134-
&self.inner
135-
}
136-
}
137-
138128
impl<T> AsRef<T> for PyObjectRc<T>
139129
where
140130
T: ?Sized + PyObjectPayload,

vm/src/stdlib/itertools.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ mod decl {
99
use std::iter;
1010

1111
use crate::common::cell::{PyMutex, PyRwLock, PyRwLockWriteGuard};
12-
use crate::common::rc::{PyRc, PyWeak};
12+
use crate::common::rc::PyRc;
1313
use crate::function::{Args, OptionalArg, OptionalOption, PyFuncArgs};
1414
use crate::obj::objbool;
1515
use crate::obj::objint::{self, PyInt, PyIntRef};
1616
use crate::obj::objiter::{call_next, get_all, get_iter, get_next_object, new_stop_iteration};
1717
use crate::obj::objtuple::PyTuple;
1818
use crate::obj::objtype::{self, PyClassRef};
1919
use crate::pyobject::{
20-
BorrowValue, IdProtocol, IntoPyRef, PyCallable, PyClassImpl, PyObject, PyObjectRef, PyRef,
21-
PyResult, PyValue, TypeProtocol,
20+
BorrowValue, IdProtocol, IntoPyRef, PyCallable, PyClassImpl, PyObjectRc, PyObjectRef,
21+
PyObjectWeak, PyRef, PyResult, PyValue, TypeProtocol,
2222
};
2323
use crate::vm::VirtualMachine;
2424

@@ -498,7 +498,7 @@ mod decl {
498498
current_value: Option<PyObjectRef>,
499499
current_key: Option<PyObjectRef>,
500500
next_group: bool,
501-
grouper: Option<PyWeak<PyObject<PyItertoolsGrouper>>>,
501+
grouper: Option<PyObjectWeak<PyItertoolsGrouper>>,
502502
}
503503

504504
impl fmt::Debug for GroupByState {
@@ -609,7 +609,7 @@ mod decl {
609609
}
610610
.into_ref(vm);
611611

612-
state.grouper = Some(PyRc::downgrade(&grouper.clone().into_typed_pyobj()));
612+
state.grouper = Some(PyObjectRc::downgrade(&grouper.clone().into_typed_pyobj()));
613613
Ok((state.current_key.as_ref().unwrap().clone(), grouper))
614614
}
615615

0 commit comments

Comments
 (0)