From 072fd8a10ca42297461f06bd8929fd697aec7960 Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 3 Dec 2024 15:00:05 +0100 Subject: [PATCH] feat: make `StatusCode::as_u16` a const fn (#680) --- src/status.rs | 4 ++-- src/uri/port.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/status.rs b/src/status.rs index 16896e4a..9ad04d20 100644 --- a/src/status.rs +++ b/src/status.rs @@ -116,8 +116,8 @@ impl StatusCode { /// assert_eq!(status.as_u16(), 200); /// ``` #[inline] - pub fn as_u16(&self) -> u16 { - (*self).into() + pub const fn as_u16(&self) -> u16 { + (*self).0.get() } /// Returns a &str representation of the `StatusCode` diff --git a/src/uri/port.rs b/src/uri/port.rs index 8f5c5f3f..2a7028e2 100644 --- a/src/uri/port.rs +++ b/src/uri/port.rs @@ -22,7 +22,7 @@ impl Port { /// let port = authority.port().unwrap(); /// assert_eq!(port.as_u16(), 80); /// ``` - pub fn as_u16(&self) -> u16 { + pub const fn as_u16(&self) -> u16 { self.port } }