I am trying to implement a very simple symbol table, that holds symbol name bytes in a single Vec<u8> and handles out opaque Copy-able "symbols" to be used in the rest of the program. I suppose that the problem is that the compiler doesn't know that the bytes in the Vec<u8> (that is part of the struct SymbolTable) will live at least as the struct itself and I don't know how to tell it.
Mm. I now understand that the compiler is saving my day. The vector data can move and change address so what I was trying to do (keep the &str alive) is wrong. The new question is "what's the right way to do what I wanted to do?"
I'd like to store the strings only once. The idea is to have opaque, copy-able handles to be used in other data structures, like graphs, but still have access to the string once the result are computed and need to be printed out. The data sets are in the order of GB and one can have several hundred MB of labels so duplicating them isn't a good idea.