File tree Expand file tree Collapse file tree 4 files changed +9
-8
lines changed Expand file tree Collapse file tree 4 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -76,14 +76,14 @@ static mut MODULE_DEF: PyModuleDef = PyModuleDef {
7676 m_name: c_str!("string_sum").as_ptr(),
7777 m_doc: c_str!("A Python module written in Rust.").as_ptr(),
7878 m_size: 0,
79- m_methods: unsafe { METHODS as *const [PyMethodDef] as *mut PyMethodDef } ,
79+ m_methods: std::ptr::addr_of_mut!( METHODS).cast() ,
8080 m_slots: unsafe { SLOTS as *const [PyModuleDef_Slot] as *mut PyModuleDef_Slot },
8181 m_traverse: None,
8282 m_clear: None,
8383 m_free: None,
8484};
8585
86- static mut METHODS: & [PyMethodDef] = & [
86+ static mut METHODS: [PyMethodDef; 2 ] = [
8787 PyMethodDef {
8888 ml_name: c_str!("sum_as_string").as_ptr(),
8989 ml_meth: PyMethodDefPointer {
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ unsafe extern "C" fn id_richcompare(
9999 }
100100}
101101
102- static mut SLOTS : & [ PyType_Slot ] = & [
102+ static mut SLOTS : [ PyType_Slot ; 6 ] = [
103103 PyType_Slot {
104104 slot : Py_tp_new ,
105105 pfunc : id_new as * mut c_void ,
@@ -132,5 +132,5 @@ pub static mut ID_SPEC: PyType_Spec = PyType_Spec {
132132 basicsize : mem:: size_of :: < PyId > ( ) as c_int ,
133133 itemsize : 0 ,
134134 flags : ( Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE ) as c_uint ,
135- slots : unsafe { SLOTS as * const [ PyType_Slot ] as * mut PyType_Slot } ,
135+ slots : ptr :: addr_of_mut! ( SLOTS ) . cast ( ) ,
136136} ;
Original file line number Diff line number Diff line change @@ -8,13 +8,14 @@ pub static mut MODULE_DEF: PyModuleDef = PyModuleDef {
88 m_doc : c_str ! ( "A library for generating sequential ids, written in Rust." ) . as_ptr ( ) ,
99 m_size : mem:: size_of :: < sequential_state > ( ) as Py_ssize_t ,
1010 m_methods : std:: ptr:: null_mut ( ) ,
11- m_slots : unsafe { SEQUENTIAL_SLOTS as * const [ PyModuleDef_Slot ] as * mut PyModuleDef_Slot } ,
11+ m_slots : std :: ptr :: addr_of_mut! ( SEQUENTIAL_SLOTS ) . cast ( ) ,
1212 m_traverse : Some ( sequential_traverse) ,
1313 m_clear : Some ( sequential_clear) ,
1414 m_free : Some ( sequential_free) ,
1515} ;
1616
17- static mut SEQUENTIAL_SLOTS : & [ PyModuleDef_Slot ] = & [
17+ const SEQUENTIAL_SLOTS_LEN : usize = 3 + if cfg ! ( Py_GIL_DISABLED ) { 1 } else { 0 } ;
18+ static mut SEQUENTIAL_SLOTS : [ PyModuleDef_Slot ; SEQUENTIAL_SLOTS_LEN ] = [
1819 PyModuleDef_Slot {
1920 slot : Py_mod_exec ,
2021 value : sequential_exec as * mut c_void ,
Original file line number Diff line number Diff line change @@ -8,14 +8,14 @@ static mut MODULE_DEF: PyModuleDef = PyModuleDef {
88 m_name : c_str ! ( "string_sum" ) . as_ptr ( ) ,
99 m_doc : c_str ! ( "A Python module written in Rust." ) . as_ptr ( ) ,
1010 m_size : 0 ,
11- m_methods : unsafe { METHODS as * const [ PyMethodDef ] as * mut PyMethodDef } ,
11+ m_methods : std :: ptr :: addr_of_mut! ( METHODS ) . cast ( ) ,
1212 m_slots : unsafe { SLOTS as * const [ PyModuleDef_Slot ] as * mut PyModuleDef_Slot } ,
1313 m_traverse : None ,
1414 m_clear : None ,
1515 m_free : None ,
1616} ;
1717
18- static mut METHODS : & [ PyMethodDef ] = & [
18+ static mut METHODS : [ PyMethodDef ; 2 ] = [
1919 PyMethodDef {
2020 ml_name : c_str ! ( "sum_as_string" ) . as_ptr ( ) ,
2121 ml_meth : PyMethodDefPointer {
You can’t perform that action at this time.
0 commit comments