Skip to content

Commit

Permalink
feat(status): implement Hash for StatusCode
Browse files Browse the repository at this point in the history
Implment the `Hash` trait for the `StatusCode` enum.
  • Loading branch information
Håvar Nøvik committed Jul 21, 2015
1 parent 7b10846 commit aa85f60
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/status.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit aa85f60

Please sign in to comment.