Skip to content

Commit 7bac128

Browse files
committed
Fix all the tests
1 parent f310036 commit 7bac128

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

vm/src/pyobject.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,18 +1558,23 @@ impl PyObject {
15581558
}
15591559

15601560
pub fn payload<T: PyValue>(&self) -> Option<&T> {
1561-
let payload: &dyn Any = &self.payload;
1562-
payload.downcast_ref()
1561+
self.payload.as_any().downcast_ref()
15631562
}
15641563
}
15651564

15661565
pub trait PyValue: fmt::Debug + 'static {
15671566
fn required_type(ctx: &PyContext) -> PyObjectRef;
15681567
}
15691568

1570-
pub trait PyObjectPayload: Any + fmt::Debug + 'static {}
1569+
pub trait PyObjectPayload: Any + fmt::Debug + 'static {
1570+
fn as_any(&self) -> &dyn Any;
1571+
}
15711572

1572-
impl<T: PyValue + 'static> PyObjectPayload for T {}
1573+
impl<T: PyValue + 'static> PyObjectPayload for T {
1574+
fn as_any(&self) -> &dyn Any {
1575+
self
1576+
}
1577+
}
15731578

15741579
impl FromPyObjectRef for PyRef<PyClass> {
15751580
fn from_pyobj(obj: &PyObjectRef) -> Self {

0 commit comments

Comments
 (0)