Merge pull request #1048 from davidhewitt/fix-from-type-ptr-doc

Fix doc for PyType::from_type_ptr
This commit is contained in:
David Hewitt 2020-07-18 12:01:05 +01:00 committed by GitHub
commit 264e8854c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)