A key thing to remember is that tagging a struct with a lifetime (<'a>) only works when that data is stored outside the struct somewhere— Anytime you write &'a mut Something<'a> you’re going to have trouble.
There’s a few ways around this for your code:
- If all the snippets are literals, you can store them as
&'static str’s instead ofStrings. (playground) - If they’re dynamically generated, you can use
Rc<str>(playground) - You can move the
SnippetHolderinto a local variable ofmain(playground)