Skip to content
Draft
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ debug = true
[workspace.dependencies]
pyo3 = { version = "0.26" }
pyo3-build-config = { version = "0.26" }

[patch.crates-io]
pyo3 = { git = "https://github.com/pyo3/pyo3.git" }
pyo3-build-config = { git = "https://github.com/pyo3/pyo3.git" }
6 changes: 4 additions & 2 deletions crates/jiter/src/py_lossless_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ impl Default for FloatMode {

const FLOAT_ERROR: &str = "Invalid float mode, should be `'float'`, `'decimal'` or `'lossless-float'`";

impl<'py> FromPyObject<'py> for FloatMode {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
impl<'py> FromPyObject<'_, 'py> for FloatMode {
type Error = PyErr;

fn extract(ob: Borrowed<'_, 'py, PyAny>) -> PyResult<Self> {
if let Ok(str_mode) = ob.extract::<&str>() {
match str_mode {
"float" => Ok(Self::Float),
Expand Down
6 changes: 4 additions & 2 deletions crates/jiter/src/py_string_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ impl Default for StringCacheMode {
}
}

impl<'py> FromPyObject<'py> for StringCacheMode {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<StringCacheMode> {
impl<'py> FromPyObject<'_, 'py> for StringCacheMode {
type Error = PyErr;

fn extract(ob: Borrowed<'_, 'py, PyAny>) -> PyResult<StringCacheMode> {
if let Ok(bool_mode) = ob.cast::<PyBool>() {
Ok(bool_mode.is_true().into())
} else if let Ok(str_mode) = ob.extract::<&str>() {
Expand Down
8 changes: 5 additions & 3 deletions crates/jiter/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl PythonParse {
///
/// # Returns
///
/// A [PyObject](https://docs.rs/pyo3/latest/pyo3/type.PyObject.html) representing the parsed JSON value.
/// A [Py<PyAny>>](https://docs.rs/pyo3/latest/pyo3/typePy<PyAny>y>.html) representing the parsed JSON value.
pub fn python_parse<'py>(&self, py: Python<'py>, json_data: &[u8]) -> JsonResult<Bound<'py, PyAny>> {
macro_rules! ppp {
($string_cache:ident, $key_check:ident, $parse_number:ident) => {
Expand Down Expand Up @@ -237,8 +237,10 @@ impl<StringCache: StringMaybeCache, KeyCheck: MaybeKeyCheck, ParseNumber: MaybeP

const PARTIAL_ERROR: &str = "Invalid partial mode, should be `'off'`, `'on'`, `'trailing-strings'` or a `bool`";

impl<'py> FromPyObject<'py> for PartialMode {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
impl<'py> FromPyObject<'_, 'py> for PartialMode {
type Error = PyErr;

fn extract(ob: Borrowed<'_, 'py, PyAny>) -> PyResult<Self> {
if let Ok(bool_mode) = ob.cast::<PyBool>() {
Ok(bool_mode.is_true().into())
} else if let Ok(str_mode) = ob.extract::<&str>() {
Expand Down
Loading