Saving a struct with itself as data member in disk

Hi all,

I need to store a vector of string on disk. And I have to do this thing mulitiple times. So, to reduce the size of data on disk I have converted that vector of string into a Trie data structure (As I just need search operation not exact string).
This is my Trie data structure

pub struct TrieNode {
    pub children: HashMap<u8, TrieNode>,
    pub is_word: bool,
}

I was using SaveFile to do all the writing in disk. As it is highly performant and I need to write whole trie again and again after some time to disk .But its is giving me Error :
thread 'test_logic' has overflowed its stack
fatal runtime error: stack overflow

I know it has something to do with nested structure, Is there any way around thi problem?
Thanks for help :slight_smile:

As far as I understand this issue on GitHub Stack-overflow for recursive data-structures · Issue #25 · avl/savefile · GitHub, you are not just encountering a problem here because the data is deeply nested, right?

You could try to just use serde instead.

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.