Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/litemap/examples/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  litemap_bincode.rs   Sprache: unbekannt

 
Spracherkennung für: .rs vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

// LiteMap is intended as a small and low-memory drop-in replacement for
// HashMap. This example demonstrates how it works with Serde.

#![no_main] // https://github.com/unicode-org/icu4x/issues/395

icu_benchmark_macros::static_setup!();

use litemap::LiteMap;

const DATA: [(&str, &str); 11] = [
    ("ar", "Arabic"),
    ("bn", "Bangla"),
    ("ccp", "Chakma"),
    ("en", "English"),
    ("es", "Spanish"),
    ("fr", "French"),
    ("ja", "Japanese"),
    ("ru", "Russian"),
    ("sr", "Serbian"),
    ("th", "Thai"),
    ("tr", "Turkish"),
];

#[allow(dead_code)]
const BINCODE: [u8; 278] = [
    1100000002000000097114600000006511497,
    98105992000000098110600000006697110103108,
    97300000009999112600000006710497107109972,
    0000000101110700000006911010310810511510420,
    000000101115700000008311297110105115104200,
    00000102114600000007011410111099104200000,
    001069780000000749711297110101115101200000,
    001141177000000082117115115105971102000000,
    01151147000000083101114981059711020000000,
    11610440000000841049710520000000116114700,
    0000084117114107105115104,
];

/// Run this function to print new data to the console.
#[allow(dead_code)]
fn generate() {
    let mut map = LiteMap::new_vec();
    for (lang, name) in DATA.iter() {
        map.try_append(lang, name).ok_or(()).unwrap_err();
    }

    let buf = bincode::serialize(&map).unwrap();
    println!("{buf:?}");
}

#[no_mangle]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
    icu_benchmark_macros::main_setup!();

    // Uncomment the following line to re-generate the binary data.
    // generate();

    let map: LiteMap<&str, &str> = bincode::deserialize(&BINCODE).unwrap();
    assert_eq!(map.get("tr"), Some(&"Turkish"));

    0
}

[Dauer der Verarbeitung: 0.19 Sekunden, vorverarbeitet 2026-06-05]