Fix lifetime in cookies returned from Cookies::list, so they can be used with Cookies::remove#40
Open
benw wants to merge 2 commits intoimbolc:mainfrom
Open
Fix lifetime in cookies returned from Cookies::list, so they can be used with Cookies::remove#40benw wants to merge 2 commits intoimbolc:mainfrom
benw wants to merge 2 commits intoimbolc:mainfrom
Conversation
This example demonstrates that currently the cookies returned
by `Cookies::list` are incompatible with `Cookies::remove`.
This will be fixed in the next commit.
```
error[E0597]: `cookies` does not live long enough
--> examples/remove_all.rs:19:15
|
18 | async fn handler(cookies: Cookies) {
| ------- binding `cookies` declared here
19 | let all = cookies.list();
| ^^^^^^^ borrowed value does not live long enough
20 | for cookie in all {
21 | cookies.remove(cookie);
| ---------------------- argument requires that `cookies` is borrowed for `'static`
22 | }
23 | }
| - `cookies` dropped here while still borrowed
```
The cookies in the jar were already 'static, but that fact was lost by the declaration of the return type. Fixes imbolc#14
Author
|
Sadly this still doesn't reliably delete all cookies, I think because domain / path etc are not propagated in the underlying cookie implementation. |
Owner
|
I guess nowadays you can just use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an example demonstrating the problem, and then a commit to fix it. See explanation in individual commits.
Fixes #14.