* The MIT License (MIT)
* Copyright (C) 2024 Huawei Device Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
use std::collections::{BTreeMap, HashMap};
use indexmap::IndexMap;
use napi_derive::napi;
#[napi]
fn get_mapping() -> HashMap<String, u32> {
let mut map = HashMap::new();
map.insert("a".to_string(), 101);
map.insert("b".to_string(), 102);
map
}
#[napi]
fn sum_mapping(nums: HashMap<String, u32>) -> u32 {
nums.into_values().sum()
}
#[napi]
fn get_btree_mapping() -> BTreeMap<String, u32> {
let mut map = BTreeMap::new();
map.insert("a".to_string(), 101);
map.insert("b".to_string(), 102);
map
}
#[napi]
fn sum_btree_mapping(nums: BTreeMap<String, u32>) -> u32 {
nums.into_values().sum()
}
#[napi]
fn get_index_mapping() -> IndexMap<String, u32> {
let mut map = IndexMap::new();
map.insert("a".to_string(), 101);
map.insert("b".to_string(), 102);
map
}
#[napi]
fn sum_index_mapping(nums: IndexMap<String, u32>) -> u32 {
nums.into_values().sum()
}
#[napi]
fn indexmap_passthrough(fixture: IndexMap<String, u32>) -> IndexMap<String, u32> {
fixture
}