Help with 'static lifetime [Solved]


Hello everyone!, new Rustacean here,

I’m using reqwest to do an HTTP multipart POST. Regarding the following function:, is there any way to use that function with an argument of type String? Why would the author use a 'static lifetime as generic argument?

Thanks in advance!


Yes you can pass a String because there’s an impl<'a> From<String> for Cow<'a, str>, where 'a will become 'static.

It’s using 'static because it wants either a string constant/literal or an owned string.


Ah, totally clear now, thanks @vitalyd.