Skip to content

Commit f1f2623

Browse files
committed
edition, clippy misc
1 parent 08d5118 commit f1f2623

4 files changed

Lines changed: 15 additions & 25 deletions

File tree

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/decode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::exc::*;
44
use crate::typeref::*;
55
use associative_cache::replacement::RoundRobinReplacement;
66
use associative_cache::*;
7+
use lazy_static::lazy_static;
78
use pyo3::prelude::*;
89
use serde::de::{self, DeserializeSeed, Deserializer, MapAccess, SeqAccess, Visitor};
910
use smallvec::SmallVec;

src/exc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
22

3+
use pyo3::create_exception;
4+
use pyo3::import_exception;
5+
36
pub const INVALID_STR: &str = "str is not valid UTF-8: surrogates not allowed";
47

58
import_exception!(json, JSONDecodeError);

src/lib.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,8 @@
33
#![feature(core_intrinsics)]
44
#![feature(const_fn)]
55

6-
#[macro_use]
7-
extern crate pyo3;
8-
9-
#[macro_use]
10-
extern crate lazy_static;
11-
12-
extern crate associative_cache;
13-
extern crate encoding_rs;
14-
extern crate itoa;
15-
extern crate parking_lot;
16-
extern crate serde;
17-
extern crate serde_json;
18-
extern crate smallvec;
19-
extern crate wyhash;
20-
216
use pyo3::prelude::*;
7+
use pyo3::wrap_pyfunction;
228
use pyo3::AsPyPointer;
239
use std::os::raw::c_char;
2410
use std::ptr::NonNull;
@@ -94,14 +80,14 @@ pub fn dumps(
9480
option: Option<PyObject>,
9581
) -> PyResult<PyObject> {
9682
let pydef: Option<NonNull<pyo3::ffi::PyObject>>;
97-
if default.is_some() {
98-
pydef = Some(unsafe { NonNull::new_unchecked(default.unwrap().as_ptr()) });
83+
if let Some(value) = default {
84+
pydef = Some(unsafe { NonNull::new_unchecked(value.as_ptr()) });
9985
} else {
10086
pydef = None
10187
};
10288
let optsbits: i8;
103-
if option.is_some() {
104-
let optsptr = option.unwrap().as_ptr();
89+
if let Some(value) = option {
90+
let optsptr = value.as_ptr();
10591
if unsafe { (*optsptr).ob_type != typeref::INT_PTR } {
10692
return Err(exc::JSONEncodeError::py_err("Invalid opts"));
10793
} else {

0 commit comments

Comments
 (0)