Merge pull request #3697 from davidhewitt/as-gil-ref

expose `Bound::as_gil_ref` and `Bound::into_gil_ref`
This commit is contained in:
Adam Reichold 2023-12-25 09:48:23 +00:00 committed by GitHub
commit ff373eb1c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -196,8 +196,9 @@ impl<'py, T> Bound<'py, T> {
unsafe { std::mem::transmute(gil_ref) }
}
/// Internal helper to get to pool references for backwards compatibility
#[doc(hidden)] // public and doc(hidden) to use in examples and tests for now
/// Casts this `Bound<T>` as the corresponding "GIL Ref" type.
///
/// This is a helper to be used for migration from the deprecated "GIL Refs" API.
pub fn as_gil_ref(&'py self) -> &'py T::AsRefTarget
where
T: HasPyGilRef,
@ -205,8 +206,10 @@ impl<'py, T> Bound<'py, T> {
unsafe { self.py().from_borrowed_ptr(self.as_ptr()) }
}
/// Internal helper to get to pool references for backwards compatibility
#[doc(hidden)] // public but hidden, to use for tests for now
/// Casts this `Bound<T>` as the corresponding "GIL Ref" type, registering the pointer on the
/// [release pool](Python::from_owned_ptr).
///
/// This is a helper to be used for migration from the deprecated "GIL Refs" API.
pub fn into_gil_ref(self) -> &'py T::AsRefTarget
where
T: HasPyGilRef,