You can put a
String inside a struct (and any user-defined type, in fact), it doesn't have to be a
&str just because it's in a
struct. In fact it's often more advisable to prefer owning types over borrowed types while you are learning the language.
&str needs a lifetime because it's a borrowed (reference) type, and when it's part of another type, the compiler needs some annotation as to how long you want the referred-to string slice to live at least. That is, a
struct may be constructed, used, and destroyed in any number of ways, and the compiler can't infer the underlying lifetime based on the type definition alone.
In contrast when you actually use a
&str in executable code (ie. a function), its lifetime will be inferred more often than not based on the way you use it.