feat(status): implement Hash for StatusCode
Implment the `Hash` trait for the `StatusCode` enum.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user