expose `Bound::as_gil_ref` and `Bound::into_gil_ref`

This commit is contained in:
David Hewitt 2023-12-24 14:34:08 +00:00
parent 6ca63b5772
commit 38abfd2eed
1 changed files with 7 additions and 4 deletions

View File

@ -183,8 +183,9 @@ impl<'py, T> Bound<'py, T> {
unsafe { std::mem::transmute(gil_ref) } unsafe { std::mem::transmute(gil_ref) }
} }
/// Internal helper to get to pool references for backwards compatibility /// Casts this `Bound<T>` as the corresponding "GIL Ref" type.
#[doc(hidden)] // public and doc(hidden) to use in examples and tests for now ///
/// 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 pub fn as_gil_ref(&'py self) -> &'py T::AsRefTarget
where where
T: HasPyGilRef, T: HasPyGilRef,
@ -192,8 +193,10 @@ impl<'py, T> Bound<'py, T> {
unsafe { self.py().from_borrowed_ptr(self.as_ptr()) } unsafe { self.py().from_borrowed_ptr(self.as_ptr()) }
} }
/// Internal helper to get to pool references for backwards compatibility /// Casts this `Bound<T>` as the corresponding "GIL Ref" type, registering the pointer on the
#[doc(hidden)] // public but hidden, to use for tests for now /// [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 pub fn into_gil_ref(self) -> &'py T::AsRefTarget
where where
T: HasPyGilRef, T: HasPyGilRef,