1 // This file is part of ICU4X. For terms of use, please see the file
2 // called LICENSE at the top level of the ICU4X source tree
3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5 // LiteMap is intended as a small and low-memory drop-in replacement for HashMap.
6 //
7 // This example does not use LiteMap. The reader may compare this HashMap example to the
8 // LiteMap example to showcase analogous operations between HashMap and LiteMap.
9
10 #![no_main] // https://github.com/unicode-org/icu4x/issues/395
11 icu_benchmark_macros::instrument!();
12
13 use icu_locale_core::subtags::{language, Language};
14 use std::collections::HashMap;
15
16 const DATA: [(Language, &str); 11] = [
17 (language!("ar"), "Arabic"),
18 (language!("bn"), "Bangla"),
19 (language!("ccp"), "Chakma"),
20 (language!("en"), "English"),
21 (language!("es"), "Spanish"),
22 (language!("fr"), "French"),
23 (language!("ja"), "Japanese"),
24 (language!("ru"), "Russian"),
25 (language!("sr"), "Serbian"),
26 (language!("th"), "Thai"),
27 (language!("tr"), "Turkish"),
28 ];
29
main()30 fn main() {
31 let map = HashMap::<Language, &str>::from_iter(DATA);
32
33 assert!(map.len() == 11);
34 assert!(map.get(&language!("th")) == Some(&"Thai"));
35 assert!(!map.contains_key(&language!("de")));
36 }
37