From aa85f609b5136cb2a9b23408a2b125c6a8a20f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5var=20N=C3=B8vik?= Date: Tue, 21 Jul 2015 21:10:47 +0200 Subject: [PATCH] feat(status): implement `Hash` for `StatusCode` Implment the `Hash` trait for the `StatusCode` enum. --- src/status.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/status.rs b/src/status.rs index c46fd9b3..9589cf9d 100644 --- a/src/status.rs +++ b/src/status.rs @@ -1,6 +1,7 @@ //! HTTP status codes use std::fmt; use std::cmp::Ordering; +use std::hash::{Hash, Hasher}; // shamelessly lifted from Teepee. I tried a few schemes, this really // does seem like the best. Improved scheme to support arbitrary status codes. @@ -533,6 +534,12 @@ impl Ord for StatusCode { } } +impl Hash for StatusCode { + fn hash(&self, state: &mut H) { + self.to_u16().hash(state); + } +} + /// The class of an HTTP `status-code`. /// /// [RFC 7231, section 6 (Response Status Codes)](https://tools.ietf.org/html/rfc7231#section-6):