Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose Bound::as_gil_ref and Bound::into_gil_ref #3697

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,20 @@ 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,
{
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,
Expand Down
Loading