diff --git a/newsfragments/3971.added.md b/newsfragments/3971.added.md new file mode 100644 index 00000000..12c0d226 --- /dev/null +++ b/newsfragments/3971.added.md @@ -0,0 +1 @@ +Implement `Default` for `GILOnceCell`. diff --git a/pyo3-ffi/src/cpython/object.rs b/pyo3-ffi/src/cpython/object.rs index 161fb50c..d0c16340 100644 --- a/pyo3-ffi/src/cpython/object.rs +++ b/pyo3-ffi/src/cpython/object.rs @@ -46,6 +46,7 @@ mod bufferinfo { } impl Py_buffer { + #[allow(clippy::new_without_default)] pub const fn new() -> Self { Py_buffer { buf: ptr::null_mut(), diff --git a/pyo3-ffi/src/pybuffer.rs b/pyo3-ffi/src/pybuffer.rs index a414f333..50bf4e61 100644 --- a/pyo3-ffi/src/pybuffer.rs +++ b/pyo3-ffi/src/pybuffer.rs @@ -27,6 +27,7 @@ pub struct Py_buffer { } impl Py_buffer { + #[allow(clippy::new_without_default)] pub const fn new() -> Self { Py_buffer { buf: ptr::null_mut(), diff --git a/src/impl_/pyclass/lazy_type_object.rs b/src/impl_/pyclass/lazy_type_object.rs index 1318e1ab..efb6ecf3 100644 --- a/src/impl_/pyclass/lazy_type_object.rs +++ b/src/impl_/pyclass/lazy_type_object.rs @@ -32,6 +32,7 @@ struct LazyTypeObjectInner { impl LazyTypeObject { /// Creates an uninitialized `LazyTypeObject`. + #[allow(clippy::new_without_default)] pub const fn new() -> Self { LazyTypeObject( LazyTypeObjectInner { diff --git a/src/sync.rs b/src/sync.rs index 38471fb7..5af49404 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -90,6 +90,7 @@ unsafe impl Sync for GILProtected where T: Send {} /// } /// # Python::with_gil(|py| assert_eq!(get_shared_list(py).len(), 0)); /// ``` +#[derive(Default)] pub struct GILOnceCell(UnsafeCell>); // T: Send is needed for Sync because the thread which drops the GILOnceCell can be different