From b1c03b7e4c7b02d45ca022eb1992db0c4784f5b6 Mon Sep 17 00:00:00 2001 From: Benjamin Morrison Date: Wed, 21 Jun 2023 17:17:55 -0400 Subject: when impl fmt::Display, use response code as u8 --- src/response.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/response.rs b/src/response.rs index 5711907..f11723b 100644 --- a/src/response.rs +++ b/src/response.rs @@ -57,27 +57,27 @@ impl Code { impl fmt::Display for Code { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let code_str = format!("{}", *self as u8); + let code_u8 = *self as u8; let msg = match self { - Code::Unknown => format!("{} UNKNOWN", code_str), - Code::Input => format!("{} INPUT", code_str), - Code::SensitiveInput => format!("{} SENSITIVE INPUT", code_str), - Code::Success => format!("{}", code_str), - Code::RedirectTemporary => format!("{} REDIRECT - TEMPORARY", code_str), - Code::RedirectPermanent => format!("{} REDIRECT - PERMANENT", code_str), - Code::TemporaryFailure => format!("{} TEMPORARY FAILURE", code_str), - Code::ServerUnavailable => format!("{} SERVER UNAVAILABLE", code_str), - Code::CgiError => format!("{} CGI ERROR", code_str), - Code::ProxyError => format!("{} PROXY ERROR", code_str), - Code::SlowDown => format!("{} SLOW DOWN", code_str), - Code::PermanentFailure => format!("{} PERMANENT FAILURE", code_str), - Code::NotFound => format!("{} NOT FOUND", code_str), - Code::Gone => format!("{} GONE", code_str), - Code::ProxyRequestRefused => format!("{} PROXY REQUEST REFUSED", code_str), - Code::BadRequest => format!("{} BAD REQUEST", code_str), - Code::ClientCertificateRequired => format!("{} CLIENT CERTIFICATE REQUIRED", code_str), - Code::CertificateNotAuthorised => format!("{} CERTIFICATE NOT AUTHORISED", code_str), - Code::CertificateNotValid => format!("{} CERTIFICATE NOT VALID", code_str), + Code::Unknown => format!("{} UNKNOWN", code_u8), + Code::Input => format!("{} INPUT", code_u8), + Code::SensitiveInput => format!("{} SENSITIVE INPUT", code_u8), + Code::Success => format!("{}", code_u8), + Code::RedirectTemporary => format!("{} REDIRECT - TEMPORARY", code_u8), + Code::RedirectPermanent => format!("{} REDIRECT - PERMANENT", code_u8), + Code::TemporaryFailure => format!("{} TEMPORARY FAILURE", code_u8), + Code::ServerUnavailable => format!("{} SERVER UNAVAILABLE", code_u8), + Code::CgiError => format!("{} CGI ERROR", code_u8), + Code::ProxyError => format!("{} PROXY ERROR", code_u8), + Code::SlowDown => format!("{} SLOW DOWN", code_u8), + Code::PermanentFailure => format!("{} PERMANENT FAILURE", code_u8), + Code::NotFound => format!("{} NOT FOUND", code_u8), + Code::Gone => format!("{} GONE", code_u8), + Code::ProxyRequestRefused => format!("{} PROXY REQUEST REFUSED", code_u8), + Code::BadRequest => format!("{} BAD REQUEST", code_u8), + Code::ClientCertificateRequired => format!("{} CLIENT CERTIFICATE REQUIRED", code_u8), + Code::CertificateNotAuthorised => format!("{} CERTIFICATE NOT AUTHORISED", code_u8), + Code::CertificateNotValid => format!("{} CERTIFICATE NOT VALID", code_u8), }; write!(f, "{}", msg) -- cgit 1.4.1