I managed to fix this by changing type of ts to String and using to_string(). I think ts, being an &str, was a reference to data of v2, so it was impossible to drop v2 without also dropping ts.
2
solved Temporary value dropped while borrowed (E0506)