• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // The reader may compare this LiteMap example with the HashMap example to see analogous
8 // operations between LiteMap and HashMap.
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 litemap::LiteMap;
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 = LiteMap::<Language, &str>::from_iter(DATA);
32 
33     assert!(map.len() == 11);
34     assert!(map.get(&language!("th")) == Some(&"Thai"));
35     assert!(map.get(&language!("de")).is_none());
36 }
37