-
Notifications
You must be signed in to change notification settings - Fork 101
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
HeaderNameon 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
HeaderNameconst(as is the case forHeaderValue) -
Have
Header::namereturnCow<'static, HeaderName>