Well, no. Why there should be? Just discard the string if you don't need it anymore.
&str
is more useful than String
when you need to only read a string, because it is only a view into the original piece of data, not its owner. You can pass it around more easily than String
, and it is copyable, so it is not consumed by the invoked methods. In this regard it is more general: if you have a String
, you can pass it to where an &str
is expected, but if you have &str
, you can only pass it to functions expecting String
if you make a new allocation.
You can find more on the differences between these two and when to use them in the official strings guide.