cookie-rs icon indicating copy to clipboard operation
cookie-rs copied to clipboard

Why CookieJar uses 'static lifetime on cookies?

Open AngelicosPhosphoros opened this issue 5 years ago • 3 comments

I just don't understand why.

As I assume, cookies lives only during request handling (from parsing http headers until finishing sending http body). Why CookieJar uses 'static attribute on definitely non-static data?

The other questions: Does it leak memory by making non-static data static? How it is making cookie data static?

The method that I am talking about is here.

AngelicosPhosphoros avatar Feb 17 '20 21:02 AngelicosPhosphoros

If I understood correctly, the all data getters of Cookie<'static> returns references with lifetime bound to reference to &Cookie itself but not to lifetime generic parameter of the struct definition.

AngelicosPhosphoros avatar Feb 18 '20 06:02 AngelicosPhosphoros

#137 - I don't think any particular reason. In this PR @SergioBenitez says he's fine with lifetime changes

rsnakard-r7 avatar Feb 18 '20 18:02 rsnakard-r7

Thank you!

AngelicosPhosphoros avatar Feb 19 '20 06:02 AngelicosPhosphoros