-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Hi,
The Header
trait requires a name
function that returns a &'static HeaderName
. However, none of the methods used to construct a HeaderName
are marked const
(and so cannot be used to create a regular static, either explicitly or via promotion of a local temporary), so there appears to only be two possible ways to write a valid implementation of Header::name
:
-
Box and then leak a
HeaderName
on every call -
Set up a
lazy_static
(or equivalent via new primitives likeLazyCell
) that uses internal mutability to lazily initiate aHeaderName
Both of these approaches are undesirable for fairly clear reasons, the first especially, which leads me to the question:
What is the intended approach when implementing this trait?
Or, alternatively, would it be possible to do one of the following?-
Make some of the methods used to create
HeaderName
const
(as is the case forHeaderValue
) -
Have
Header::name
returnCow<'static, HeaderName>