@@ -21,33 +21,33 @@ mod os;
21
21
22
22
use crate :: pyobject:: { PyContext , PyObjectRef } ;
23
23
24
- pub type StdlibInitFunc = fn ( & PyContext ) -> PyObjectRef ;
24
+ pub type StdlibInitFunc = Box < dyn Fn ( & PyContext ) -> PyObjectRef > ;
25
25
26
26
pub fn get_module_inits ( ) -> HashMap < String , StdlibInitFunc > {
27
27
let mut modules = HashMap :: new ( ) ;
28
- modules. insert ( "ast" . to_string ( ) , ast:: mk_module as StdlibInitFunc ) ;
29
- modules. insert ( "dis" . to_string ( ) , dis:: mk_module as StdlibInitFunc ) ;
30
- modules. insert ( "json" . to_string ( ) , json:: mk_module as StdlibInitFunc ) ;
31
- modules. insert ( "keyword" . to_string ( ) , keyword:: mk_module as StdlibInitFunc ) ;
32
- modules. insert ( "math" . to_string ( ) , math:: mk_module as StdlibInitFunc ) ;
33
- modules. insert ( "re" . to_string ( ) , re:: mk_module as StdlibInitFunc ) ;
34
- modules. insert ( "random" . to_string ( ) , random:: mk_module as StdlibInitFunc ) ;
35
- modules. insert ( "string" . to_string ( ) , string:: mk_module as StdlibInitFunc ) ;
36
- modules. insert ( "struct" . to_string ( ) , pystruct:: mk_module as StdlibInitFunc ) ;
37
- modules. insert ( "time" . to_string ( ) , time_module:: mk_module as StdlibInitFunc ) ;
38
28
modules. insert (
39
- "tokenize " . to_string ( ) ,
40
- tokenize :: mk_module as StdlibInitFunc ,
29
+ "ast " . to_string ( ) ,
30
+ Box :: new ( ast :: mk_module) as StdlibInitFunc ,
41
31
) ;
42
- modules. insert ( "types" . to_string ( ) , types:: mk_module as StdlibInitFunc ) ;
43
- modules. insert ( "_weakref" . to_string ( ) , weakref:: mk_module as StdlibInitFunc ) ;
32
+ modules. insert ( "dis" . to_string ( ) , Box :: new ( dis:: mk_module) ) ;
33
+ modules. insert ( "json" . to_string ( ) , Box :: new ( json:: mk_module) ) ;
34
+ modules. insert ( "keyword" . to_string ( ) , Box :: new ( keyword:: mk_module) ) ;
35
+ modules. insert ( "math" . to_string ( ) , Box :: new ( math:: mk_module) ) ;
36
+ modules. insert ( "re" . to_string ( ) , Box :: new ( re:: mk_module) ) ;
37
+ modules. insert ( "random" . to_string ( ) , Box :: new ( random:: mk_module) ) ;
38
+ modules. insert ( "string" . to_string ( ) , Box :: new ( string:: mk_module) ) ;
39
+ modules. insert ( "struct" . to_string ( ) , Box :: new ( pystruct:: mk_module) ) ;
40
+ modules. insert ( "time" . to_string ( ) , Box :: new ( time_module:: mk_module) ) ;
41
+ modules. insert ( "tokenize" . to_string ( ) , Box :: new ( tokenize:: mk_module) ) ;
42
+ modules. insert ( "types" . to_string ( ) , Box :: new ( types:: mk_module) ) ;
43
+ modules. insert ( "_weakref" . to_string ( ) , Box :: new ( weakref:: mk_module) ) ;
44
44
45
45
// disable some modules on WASM
46
46
#[ cfg( not( target_arch = "wasm32" ) ) ]
47
47
{
48
- modules. insert ( "io" . to_string ( ) , io:: mk_module as StdlibInitFunc ) ;
49
- modules. insert ( "os" . to_string ( ) , os:: mk_module as StdlibInitFunc ) ;
50
- modules. insert ( "socket" . to_string ( ) , socket:: mk_module as StdlibInitFunc ) ;
48
+ modules. insert ( "io" . to_string ( ) , Box :: new ( io:: mk_module) ) ;
49
+ modules. insert ( "os" . to_string ( ) , Box :: new ( os:: mk_module) ) ;
50
+ modules. insert ( "socket" . to_string ( ) , Box :: new ( socket:: mk_module) ) ;
51
51
}
52
52
53
53
modules
0 commit comments