4 stable releases
2024.12.3 | Dec 3, 2024 |
---|---|
2024.12.2 | Dec 2, 2024 |
2024.12.1 | Dec 1, 2024 |
2024.11.29 | Nov 29, 2024 |
#96 in FFI
584 downloads per month
Used in asc_bin
9KB
128 lines
Call Rust Vec, std::collections::{BTreeMap, BTreeSet} in C
// copy ../c_source_parser_ffi/src/rs_container_ffi/btree_map.h
// full example can be found at ../c_source_parser_ffi
// use rust BTreeMap<String, BTreeSet<String>>
// new BTreeMap<String, BTreeSet<String>>
RustBtreeMapOfStrSet map = rust_btree_set_of_str_new();
// insert key and value to BTreeMap<String, BTreeSet<String>>
rust_btree_set_of_str_insert(map, "key", "value");
// drop BTreeMap<String, BTreeSet<String>>
rust_btree_set_of_str_drop(map);
// use rust BTreeSet<String>
// new BTreeSet<String>
RustBtreeSetOfStr set = rust_btree_set_of_str_new();
// insert foo to BTreeSet<String>
rust_btree_set_of_str_insert(set, "foo");
// insert bar to BTreeSet<String>
rust_btree_set_of_str_insert(set, "bar");
// if foo in BTreeSet<String> return 1 else 0
int is_foo_exists = rust_btree_set_of_str_contains(set, "foo");
// drop BTreeSet<String>
rust_btree_set_of_str_drop(set);
// use rust Vec<String>
// new Vec<String>
RustVecOfStr vec = rust_vec_of_str_new();
// push a to Vec<String>
rust_vec_of_str_push(vec, "a");
// push b to Vec<String>
rust_vec_of_str_push(vec, "b");
// push c to Vec<String>
rust_vec_of_str_push(vec, "c");
// push d to Vec<String>
rust_vec_of_str_push(vec, "d");
// reverse Vec<String>
rust_vec_of_str_reverse(vec);
// join Vec<String>
const char *text = rust_vec_of_str_join("/"); // d/c/b/c
// drop Vec<String>
rust_vec_of_str_drop(vec)
// drop text (do not use c free or c++ delete)
rust_c_str_drop(text);