feat(status): implement Hash for StatusCode
Change hash implementation to just use `derive(Hash)`
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
//! HTTP status codes
|
//! HTTP status codes
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::hash::{Hash, Hasher};
|
|
||||||
|
|
||||||
// shamelessly lifted from Teepee. I tried a few schemes, this really
|
// shamelessly lifted from Teepee. I tried a few schemes, this really
|
||||||
// does seem like the best. Improved scheme to support arbitrary status codes.
|
// 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
|
/// 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
|
/// the source for this enum (with one exception, 418 I'm a teapot, which is
|
||||||
/// inexplicably not in the register).
|
/// inexplicably not in the register).
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Hash)]
|
||||||
pub enum StatusCode {
|
pub enum StatusCode {
|
||||||
/// 100 Continue
|
/// 100 Continue
|
||||||
/// [[RFC7231, Section 6.2.1](https://tools.ietf.org/html/rfc7231#section-6.2.1)]
|
/// [[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<H: Hasher>(&self, state: &mut H) {
|
|
||||||
self.to_u16().hash(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The class of an HTTP `status-code`.
|
/// The class of an HTTP `status-code`.
|
||||||
///
|
///
|
||||||
/// [RFC 7231, section 6 (Response Status Codes)](https://tools.ietf.org/html/rfc7231#section-6):
|
/// [RFC 7231, section 6 (Response Status Codes)](https://tools.ietf.org/html/rfc7231#section-6):
|
||||||
|
|||||||
Reference in New Issue
Block a user