From f8a6a4346a76a941e33ab1f259540fe827fe2f5d Mon Sep 17 00:00:00 2001 From: Cosmic Horror Date: Sun, 25 May 2025 00:31:39 -0600 Subject: [PATCH] feat: const `::from_static()` constructors --- src/common/referer.rs | 2 +- src/common/server.rs | 2 +- src/common/user_agent.rs | 2 +- src/util/value_string.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/referer.rs b/src/common/referer.rs index 2a31df36..85021f13 100644 --- a/src/common/referer.rs +++ b/src/common/referer.rs @@ -43,7 +43,7 @@ impl Referer { /// # Panic /// /// Panics if the string is not a legal header value. - pub fn from_static(s: &'static str) -> Referer { + pub const fn from_static(s: &'static str) -> Referer { Referer(HeaderValueString::from_static(s)) } } diff --git a/src/common/server.rs b/src/common/server.rs index 543c97dd..870d083a 100644 --- a/src/common/server.rs +++ b/src/common/server.rs @@ -43,7 +43,7 @@ impl Server { /// # Panic /// /// Panics if the static string is not a legal header value. - pub fn from_static(s: &'static str) -> Server { + pub const fn from_static(s: &'static str) -> Server { Server(HeaderValueString::from_static(s)) } diff --git a/src/common/user_agent.rs b/src/common/user_agent.rs index b5c6339c..57f0d944 100644 --- a/src/common/user_agent.rs +++ b/src/common/user_agent.rs @@ -52,7 +52,7 @@ impl UserAgent { /// # Panic /// /// Panics if the static string is not a legal header value. - pub fn from_static(src: &'static str) -> UserAgent { + pub const fn from_static(src: &'static str) -> UserAgent { UserAgent(HeaderValueString::from_static(src)) } diff --git a/src/util/value_string.rs b/src/util/value_string.rs index 303eceec..71870ca3 100644 --- a/src/util/value_string.rs +++ b/src/util/value_string.rs @@ -35,7 +35,7 @@ impl HeaderValueString { .map(|value| HeaderValueString { value }) } - pub(crate) fn from_static(src: &'static str) -> HeaderValueString { + pub(crate) const fn from_static(src: &'static str) -> HeaderValueString { // A valid `str` (the argument)... HeaderValueString { value: HeaderValue::from_static(src),