Skip to content

Commit 8000235

Browse files
committed
&PyObject::try_to_ref
1 parent 64e1df5 commit 8000235

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

vm/src/convert/try_from.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ impl PyObject {
3838
T::try_from_borrowed_object(vm, self)
3939
}
4040

41+
pub fn try_to_ref<'a, T: 'a>(&'a self, vm: &VirtualMachine) -> PyResult<&'a Py<T>>
42+
where
43+
T: PyPayload,
44+
{
45+
self.try_to_value::<&Py<T>>(vm)
46+
}
47+
4148
pub fn try_value_with<T, F, R>(&self, f: F, vm: &VirtualMachine) -> PyResult<R>
4249
where
4350
T: PyPayload,

0 commit comments

Comments
 (0)