Yes, but I would like to create a new &str with the same lifetime that '_t' without changing the lifetime of 's'. Although I think that's not possible and this question makes no sense
Ah, I see. I’m not sure that you can “change” or “assign” a lifetime in the manner you’re trying. Lifetimes are more descriptive than something you control. And when you declare them explicitly, it’s more to inform the compiler of lifetime bounds it may not be able to deduce, rather than to “give” objects a lifetime. If my understanding is incorrect, please feel free to correct.
I’m not as knowledgeable about unsafe rust, but you may be able to manipulate lifetimes in some (not recommended) way there, if really needed.
Can you explain more about what issue you’re trying to solve with your code?
The data needs to be stored in some sort of container that lives long enough. One option would be to have t be mutable and write to it, although it requires t to have enough space or that you have access to the underlying String so you can extend it if it's too short.
Keep in mind that lifetimes don't do anything, and they can't make something live long enough. They only describe what the program is already doing, so that the compiler can check if that's sensible. For example, the alternative mrustc compiler doesn't understand lifetimes, and ignores them completely, and can still run Rust code properly.
&str is not a string in itself, but a view of some other String (or a similar owned type) that lives elsewhere and already has its own lifetime dictated by the code that created it and destroys it. So you can't remotely make something else, somewhere else, live longer.
You probably shouldn't be using &str for this, and use String as the return type.