simplify implementation of `Py::clone_ref` (#4313)

This commit is contained in:
David Hewitt 2024-07-07 07:53:43 +01:00 committed by GitHub
parent 59c4fa3f24
commit d5c886f4c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -1329,8 +1329,11 @@ impl<T> Py<T> {
/// # }
/// ```
#[inline]
pub fn clone_ref(&self, py: Python<'_>) -> Py<T> {
unsafe { Py::from_borrowed_ptr(py, self.0.as_ptr()) }
pub fn clone_ref(&self, _py: Python<'_>) -> Py<T> {
unsafe {
ffi::Py_INCREF(self.as_ptr());
Self::from_non_null(self.0)
}
}
/// Drops `self` and immediately decreases its reference count.