We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1d9ddb1 commit 5ba5778Copy full SHA for 5ba5778
1 file changed
src/status.rs
@@ -131,7 +131,14 @@ impl StatusCode {
131
/// ```
132
#[inline]
133
pub fn as_str(&self) -> &str {
134
- CODES_AS_STR[(self.0.get() - 100) as usize]
+ let offset = (self.0.get() - 100) as usize;
135
+ let offset = offset * 3;
136
+
137
+ unsafe {
138
+ CODES_AS_STR
139
+ .get_unchecked(offset..)
140
+ .get_unchecked(..3)
141
+ }
142
}
143
144
/// Get the standardised `reason-phrase` for this status code.
@@ -528,7 +535,11 @@ impl Error for InvalidStatusCode {}
528
535
529
536
macro_rules! status_code_strs {
530
537
($($num:expr,)+) => {
531
- const CODES_AS_STR: [&'static str; 900] = [ $( stringify!($num), )+ ];
538
+ const CODES_AS_STR: &'static str = concat!(
539
+ $(
540
+ stringify!($num) ,
541
+ )+
542
+ );
532
543
533
544
534
545
0 commit comments