Skip to content

Commit b6b8f6e

Browse files
committed
Have stdlib::get_module_inits() use maplit::hashmap!
1 parent ffeaf2d commit b6b8f6e

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

vm/src/stdlib/mod.rs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,27 @@ use crate::pyobject::PyObjectRef;
3434
pub type StdlibInitFunc = Box<dyn Fn(&VirtualMachine) -> PyObjectRef>;
3535

3636
pub fn get_module_inits() -> HashMap<String, StdlibInitFunc> {
37-
let mut modules = HashMap::new();
38-
modules.insert(
39-
"ast".to_string(),
40-
Box::new(ast::make_module) as StdlibInitFunc,
41-
);
42-
modules.insert("binascii".to_string(), Box::new(binascii::make_module));
43-
modules.insert("dis".to_string(), Box::new(dis::make_module));
44-
modules.insert("itertools".to_string(), Box::new(itertools::make_module));
45-
modules.insert("json".to_string(), Box::new(json::make_module));
46-
modules.insert("keyword".to_string(), Box::new(keyword::make_module));
47-
modules.insert("marshal".to_string(), Box::new(marshal::make_module));
48-
modules.insert("math".to_string(), Box::new(math::make_module));
49-
modules.insert("platform".to_string(), Box::new(platform::make_module));
50-
modules.insert("re".to_string(), Box::new(re::make_module));
51-
modules.insert("random".to_string(), Box::new(random::make_module));
52-
modules.insert("string".to_string(), Box::new(string::make_module));
53-
modules.insert("struct".to_string(), Box::new(pystruct::make_module));
54-
modules.insert("_thread".to_string(), Box::new(thread::make_module));
55-
modules.insert("time".to_string(), Box::new(time_module::make_module));
56-
modules.insert("tokenize".to_string(), Box::new(tokenize::make_module));
57-
modules.insert("_weakref".to_string(), Box::new(weakref::make_module));
58-
modules.insert("_imp".to_string(), Box::new(imp::make_module));
59-
modules.insert("_warnings".to_string(), Box::new(warnings::make_module));
37+
let mut modules = hashmap! {
38+
"ast".to_string() => Box::new(ast::make_module) as StdlibInitFunc,
39+
"binascii".to_string() => Box::new(binascii::make_module),
40+
"dis".to_string() => Box::new(dis::make_module),
41+
"itertools".to_string() => Box::new(itertools::make_module),
42+
"json".to_string() => Box::new(json::make_module),
43+
"keyword".to_string() => Box::new(keyword::make_module),
44+
"marshal".to_string() => Box::new(marshal::make_module),
45+
"math".to_string() => Box::new(math::make_module),
46+
"platform".to_string() => Box::new(platform::make_module),
47+
"re".to_string() => Box::new(re::make_module),
48+
"random".to_string() => Box::new(random::make_module),
49+
"string".to_string() => Box::new(string::make_module),
50+
"struct".to_string() => Box::new(pystruct::make_module),
51+
"_thread".to_string() => Box::new(thread::make_module),
52+
"time".to_string() => Box::new(time_module::make_module),
53+
"tokenize".to_string() => Box::new(tokenize::make_module),
54+
"_weakref".to_string() => Box::new(weakref::make_module),
55+
"_imp".to_string() => Box::new(imp::make_module),
56+
"_warnings".to_string() => Box::new(warnings::make_module),
57+
};
6058

6159
// disable some modules on WASM
6260
#[cfg(not(target_arch = "wasm32"))]

0 commit comments

Comments
 (0)