From d84f291abc0a64e270143eee943a76a7aebec029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5var=20N=C3=B8vik?= Date: Wed, 22 Jul 2015 10:50:26 +0200 Subject: [PATCH] feat(status): implement `Hash` for `StatusCode` Change hash implementation to just use `derive(Hash)` --- src/status.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/status.rs b/src/status.rs index 9589cf9de8..fc5eda4990 100644 --- a/src/status.rs +++ b/src/status.rs @@ -1,7 +1,6 @@ //! 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. @@ -29,7 +28,7 @@ use std::hash::{Hash, Hasher}; /// Registry](http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) which is /// the source for this enum (with one exception, 418 I'm a teapot, which is /// inexplicably not in the register). -#[derive(Debug)] +#[derive(Debug, Hash)] pub enum StatusCode { /// 100 Continue /// [[RFC7231, Section 6.2.1](https://tools.ietf.org/html/rfc7231#section-6.2.1)] @@ -534,12 +533,6 @@ 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):