We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
map
1 parent 4af18c0 commit 11fdba2Copy full SHA for 11fdba2
crates/bevy_mod_scripting_functions/src/core.rs
@@ -656,6 +656,25 @@ impl GlobalNamespace {
656
&mut allocator,
657
))
658
}
659
+
660
+ /// Constructs a hash map. Useful for languages which do not make the distinction between lists and dictionaries.
661
+ ///
662
+ /// Arguments:
663
+ /// * `map_or_list`: The list or map to convert to a hash map.
664
+ /// Returns:
665
+ /// * `hashMap`: The converted hash map
666
+ fn map(
667
+ map_or_list: Union<HashMap<String, ScriptValue>, Vec<ScriptValue>>,
668
+ ) -> HashMap<String, ScriptValue> {
669
+ match map_or_list.into_left() {
670
+ Ok(map) => map,
671
+ Err(list) => list
672
+ .into_iter()
673
+ .enumerate()
674
+ .map(|(k, v)| (k.to_string(), v))
675
+ .collect(),
676
+ }
677
678
679
680
pub fn register_core_functions(app: &mut App) {
0 commit comments