Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature suggestion for trillium: Lifetimes of Headers::get should be more flexible #310

Closed
divergentdave opened this issue Apr 10, 2023 · 1 comment

Comments

@divergentdave
Copy link
Contributor

In a function that takes &Conn, I tried passing a String to conn.request_headers().get(...), and I got a lifetime error. This method's signature is pub fn get<'a>(&'a self, name: impl Into<HeaderName<'a>>) -> Option<&'a HeaderValue>. The string implements Into<HeaderName<'static>>, but of course the lifetime of the connection reference is not 'static. I was able to fix my error by writing conn.request_headers().get(string.as_str()) instead. I think the method signature should be changed to pub fn get<'a, 'b>(&'a self, name: impl Into<HeaderName<'b>>) -> Option<&'a HeaderValue> if possible, since the name is not part of the returned value.

@jbr
Copy link
Contributor

jbr commented Apr 10, 2023

closed in #312, released as trillium-http@v0.2.14

@jbr jbr closed this as completed Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants