Add Module::combine.

This commit is contained in:
Stephen Chung 2020-08-15 00:08:00 +08:00
parent a5b4d61dff
commit 489b1ca00e
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@ New features
------------ ------------
* Adds `Engine::register_get_result`, `Engine::register_set_result`, `Engine::register_indexer_get_result`, `Engine::register_indexer_set_result` API. * Adds `Engine::register_get_result`, `Engine::register_set_result`, `Engine::register_indexer_get_result`, `Engine::register_indexer_set_result` API.
* Adds `Module::combine` to combine two modules.
Version 0.18.1 Version 0.18.1

View File

@ -928,6 +928,18 @@ impl Module {
self.all_functions.get(&hash_qualified_fn) self.all_functions.get(&hash_qualified_fn)
} }
/// Combine another module into this module.
/// The other module is consumed to merge into this module.
pub fn combine(&mut self, other: Self) -> &mut Self {
self.variables.extend(other.variables.into_iter());
self.functions.extend(other.functions.into_iter());
self.type_iterators.extend(other.type_iterators.into_iter());
self.all_functions.clear();
self.all_variables.clear();
self.indexed = false;
self
}
/// Merge another module into this module. /// Merge another module into this module.
pub fn merge(&mut self, other: &Self) -> &mut Self { pub fn merge(&mut self, other: &Self) -> &mut Self {
self.merge_filtered(other, |_, _, _| true) self.merge_filtered(other, |_, _, _| true)