So far I didn't manage to pass something as value that is not static, which makes the struct implementation relatively useless to me. Of course there has to be a way to pass dynamically created strings to this method, right?
You would at least want to have dynamic cookie values, wouldn't I?
This works because String: 'static. You can also pass in string literals, but you wanted dynamically created string. So you must allocate a new string.
Adding your advised to_string to the parameters, fixed the problem partly.
I still get:
error[E0716]: temporary value dropped while borrowed
--> src/utils.rs:80:28
|
80 | cookie.set_domain(&self.domain.to_string());
| -------------------^^^^^^^^^^^^^^^^^^^^^^^-- temporary value is freed at the end of this statement
| | |
| | creates a temporary which is freed while still in use
| argument requires that borrow lasts for `'static`
You need to allocate, note how the parameter must implement Into<Cow<'static, str>>. This means that the parameter can be one of, &'static str, String, Cow<'static, str>. So you can do,
cookie.set_domain(self.domain.to_string());
It looks like this is how all of the relevant functions on Cookie work.