Feature suggestion for trillium
: Lifetimes of Headers::get should be more flexible
#310
Labels
trillium
: Lifetimes of Headers::get should be more flexible
#310
In a function that takes
&Conn
, I tried passing aString
toconn.request_headers().get(...)
, and I got a lifetime error. This method's signature ispub fn get<'a>(&'a self, name: impl Into<HeaderName<'a>>) -> Option<&'a HeaderValue>
. The string implementsInto<HeaderName<'static>>
, but of course the lifetime of the connection reference is not'static
. I was able to fix my error by writingconn.request_headers().get(string.as_str())
instead. I think the method signature should be changed topub 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.The text was updated successfully, but these errors were encountered: