Update PyBytes::from_ptr docstring to reflect its usage

This commit is contained in:
Nicholas Sim 2021-01-18 18:31:38 +08:00
parent 5eeeb2cca9
commit 189ea208ca
1 changed files with 4 additions and 2 deletions

View File

@ -70,8 +70,10 @@ impl PyBytes {
/// ///
/// # Safety /// # Safety
/// ///
/// This function dereferences the raw pointer `ptr`, /// This function dereferences the raw pointer `ptr` as the
/// [which is an unsafe operation](https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#unsafe-superpowers). /// leading pointer of a slice of length `len`. [As with
/// `std::slice::from_raw_parts`, this is
/// unsafe](https://doc.rust-lang.org/std/slice/fn.from_raw_parts.html#safety).
pub unsafe fn from_ptr(py: Python<'_>, ptr: *const u8, len: usize) -> &PyBytes { pub unsafe fn from_ptr(py: Python<'_>, ptr: *const u8, len: usize) -> &PyBytes {
py.from_owned_ptr(ffi::PyBytes_FromStringAndSize( py.from_owned_ptr(ffi::PyBytes_FromStringAndSize(
ptr as *const _, ptr as *const _,