Make a way to make const zeroed PyMethodDef

This commit is contained in:
mejrs 2022-08-22 22:25:02 +02:00
parent 819a28bdd4
commit 3845e3fe33

View file

@ -94,6 +94,19 @@ pub struct PyMethodDef {
pub ml_doc: *const c_char,
}
impl PyMethodDef {
pub const fn zeroed() -> PyMethodDef {
PyMethodDef {
ml_name: ptr::null(),
ml_meth: PyMethodDefPointer {
Void: ptr::null_mut(),
},
ml_flags: 0,
ml_doc: ptr::null(),
}
}
}
impl Default for PyMethodDef {
fn default() -> PyMethodDef {
PyMethodDef {
@ -147,6 +160,12 @@ impl PyMethodDefPointer {
pub fn is_null(&self) -> bool {
self.as_ptr().is_null()
}
pub const fn zeroed() -> PyMethodDefPointer {
PyMethodDefPointer {
Void: ptr::null_mut(),
}
}
}
impl PartialEq for PyMethodDefPointer {