@@ -12,6 +12,7 @@ mod array {
1212 str:: wchar_t,
1313 } ,
1414 vm:: {
15+ atomic_func,
1516 builtins:: {
1617 PositionIterInternal , PyByteArray , PyBytes , PyBytesRef , PyDictRef , PyFloat , PyInt ,
1718 PyIntRef , PyList , PyListRef , PyStr , PyStrRef , PyTupleRef , PyTypeRef ,
@@ -1252,20 +1253,23 @@ mod array {
12521253 } ;
12531254
12541255 impl AsMapping for PyArray {
1255- const AS_MAPPING : PyMappingMethods = PyMappingMethods {
1256- length : Some ( |mapping, _vm| Ok ( Self :: mapping_downcast ( mapping) . len ( ) ) ) ,
1257- subscript : Some ( |mapping, needle, vm| {
1258- Self :: mapping_downcast ( mapping) . _getitem ( needle, vm)
1259- } ) ,
1260- ass_subscript : Some ( |mapping, needle, value, vm| {
1261- let zelf = Self :: mapping_downcast ( mapping) ;
1262- if let Some ( value) = value {
1263- Self :: _setitem ( zelf. to_owned ( ) , needle, value, vm)
1264- } else {
1265- zelf. _delitem ( needle, vm)
1266- }
1267- } ) ,
1268- } ;
1256+ fn as_mapping ( ) -> & ' static PyMappingMethods {
1257+ static AS_MAPPING : PyMappingMethods = PyMappingMethods {
1258+ length : atomic_func ! ( |mapping, _vm| Ok ( PyArray :: mapping_downcast( mapping) . len( ) ) ) ,
1259+ subscript : atomic_func ! ( |mapping, needle, vm| {
1260+ PyArray :: mapping_downcast( mapping) . _getitem( needle, vm)
1261+ } ) ,
1262+ ass_subscript : atomic_func ! ( |mapping, needle, value, vm| {
1263+ let zelf = PyArray :: mapping_downcast( mapping) ;
1264+ if let Some ( value) = value {
1265+ PyArray :: _setitem( zelf. to_owned( ) , needle, value, vm)
1266+ } else {
1267+ zelf. _delitem( needle, vm)
1268+ }
1269+ } ) ,
1270+ } ;
1271+ & AS_MAPPING
1272+ }
12691273 }
12701274
12711275 impl Iterable for PyArray {
0 commit comments