Fix doc for PyType::from_type_ptr

This commit is contained in:
David Hewitt 2020-07-17 18:18:36 +01:00
parent d9d095cd27
commit 9f3e13ef4d
1 changed files with 4 additions and 2 deletions

View File

@ -29,8 +29,10 @@ impl PyType {
}
/// Retrieves the `PyType` instance for the given FFI pointer.
/// This increments the reference count on the type object.
/// Undefined behavior if the pointer is NULL or invalid.
///
/// # Safety
/// - The pointer must be non-null.
/// - The pointer must be valid for the entire of the lifetime for which the reference is used.
#[inline]
pub unsafe fn from_type_ptr(py: Python, p: *mut ffi::PyTypeObject) -> &PyType {
py.from_borrowed_ptr(p as *mut ffi::PyObject)