Skip to content

Commit 34a96df

Browse files
authored
stop clippy warnings (#78)
1 parent c31fc7d commit 34a96df

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/py_string_cache.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::cell::RefCell;
22

33
use ahash::random_state::RandomState;
44
use pyo3::exceptions::{PyTypeError, PyValueError};
5-
use pyo3::ffi;
65
use pyo3::prelude::*;
76
use pyo3::sync::{GILOnceCell, GILProtected};
87
use pyo3::types::{PyBool, PyString};
@@ -197,17 +196,17 @@ pub fn pystring_fast_new<'py>(py: Python<'py>, s: &str, ascii_only: bool) -> Bou
197196
/// https://github.com/ijl/orjson/blob/3.10.0/src/str/create.rs#L41
198197
#[cfg(not(PyPy))]
199198
unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
200-
let ptr = ffi::PyUnicode_New(s.len() as isize, 127);
199+
let ptr = pyo3::ffi::PyUnicode_New(s.len() as isize, 127);
201200
// see https://github.com/pydantic/jiter/pull/72#discussion_r1545485907
202-
debug_assert_eq!(ffi::PyUnicode_KIND(ptr), ffi::PyUnicode_1BYTE_KIND);
203-
let data_ptr = ffi::PyUnicode_DATA(ptr).cast();
201+
debug_assert_eq!(pyo3::ffi::PyUnicode_KIND(ptr), pyo3::ffi::PyUnicode_1BYTE_KIND);
202+
let data_ptr = pyo3::ffi::PyUnicode_DATA(ptr).cast();
204203
core::ptr::copy_nonoverlapping(s.as_ptr(), data_ptr, s.len());
205204
core::ptr::write(data_ptr.add(s.len()), 0);
206205
Bound::from_owned_ptr(py, ptr).downcast_into_unchecked()
207206
}
208207

209-
// ffi::PyUnicode_DATA seems to be broken for pypy, hence this
208+
// ffi::PyUnicode_DATA seems to be broken for pypy, hence this, marked as unsafe to avoid warnings
210209
#[cfg(PyPy)]
211-
fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
210+
unsafe fn pystring_ascii_new<'py>(py: Python<'py>, s: &str) -> Bound<'py, PyString> {
212211
PyString::new_bound(py, s)
213212
}

0 commit comments

Comments
 (0)