String storage and string slice in the same struct
From what I've read (and experienced) you can't have a struct own storage and also borrow it. I would like to have a struct like
struct File<'a> {
source: String
symbols: HashMap<&'a str, Symbol>
ast: ASTRoot<'a>
}
where the symbols and ast are borrowing the source String. Is there a smarter way to do what I want? Obviously I could make my own string-type that contains the offsets and lengths but it's not very ergonomic. I don't want to allocate a million tiny strings... Is this something that will work in the future?