feat(status): implement Hash for StatusCode

Implment the `Hash` trait for the `StatusCode` enum.
This commit is contained in:
Håvar Nøvik
2015-07-21 21:10:47 +02:00
parent 7b108466f6
commit aa85f609b5

View File

@@ -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<H: Hasher>(&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):