Implement static's trie-tree?

I want implement static's trie-tree in myself project.
I can initialization, but cann't add node when project is running.

use std::sync::RwLock;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

use crate::service::character::character_util::{CharacterUtil};

lazy_static! {
    static ref TRIE_TREE_P: RwLock<GaeaTrieTree> = RwLock::new(GaeaTrieTree::new());

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GaeaTrieTree {
    pub is_word: bool,
    pub next_id_map: HashMap<i32, GaeaTrieTree>,

impl GaeaTrieTree {
    pub fn new() -> GaeaTrieTree {
            is_word: false,
            next_id_map: HashMap::new(),

    pub fn insert_by_query(query: String) {
        if query.len() == 0 {
        let id_list: Vec<i32> = CharacterUtil::query_to_id_list(query);

        let mut new_trie_tree = &mut TRIE_TREE_P.write().unwrap();

        for id in id_list {
            let mid_map = new_trie_tree.next_id_map;
            if !mid_map.contains_key(&id) {
                mid_map.insert(id, GaeaTrieTree::new());

            new_trie_tree = match mid_map.get(&id) {
                Some(tree) => tree,
                None => return

        new_trie_tree.is_word = true;

    pub fn get_tree_info() {
        let config_info =;
        println!("config: \n{:?}", config_info);

What should I do?

  1. Please format the code according tothis post - it's currently hard to read.
  2. This code doesn't attempt to do anything at runtime, since it doesn't have the main function. How does the non-working code look like?

i can't impl......
Finally I used c++ :sweat_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.