Remove DerefToPyType for &DerefToPyType
@@ -12,11 +12,12 @@ use crate::{
pyclass::{PyClassImpl, StaticType},
pyobject::PyLease,
types::{Callable, GetAttr, PyTypeFlags, PyTypeSlots, SetAttr},
- IdProtocol, PyContext, PyObjectRef, PyObjectWeak, PyRef, PyResult, PyValue, TypeProtocol,
- VirtualMachine,
+ IdProtocol, PyContext, PyObject, PyObjectRef, PyObjectWeak, PyRef, PyResult, PyValue,
+ TypeProtocol, VirtualMachine,
};
use itertools::Itertools;
use std::{
+ borrow::Borrow,
collections::{HashMap, HashSet},
fmt,
ops::Deref,
@@ -793,7 +794,7 @@ impl PyLease<'_, PyType> {
}
}
-pub trait DerefToPyType {
+pub trait DerefToPyType: Borrow<PyObject> {
fn deref_to_type(&self) -> &PyType;
/// Determines if `subclass` is actually a subclass of `cls`, this doesn't call __subclasscheck__,
@@ -819,12 +820,6 @@ impl<'a> DerefToPyType for PyLease<'a, PyType> {
}
}
-impl<T: DerefToPyType> DerefToPyType for &'_ T {
- fn deref_to_type(&self) -> &PyType {
- (&**self).deref_to_type()
- }
-}
-
pub(crate) fn call_slot_new(
typ: PyTypeRef,
subtype: PyTypeRef,
