I want a parser struct that owns its input and also keeps a slice into it: struct Parser { text: String, current: &str }. First the compiler demands a lifetime on current. After adding <'a>, my constructor, which creates the String and then sets current to &text[..], fails because text cannot be moved while it is borrowed, or because the function returns a value referencing data it owns.
The heap data of a String does not move when the struct moves, so why is this rejected, and how do people structure code like this?




