refactor(lib): rename http_types to http
This commit is contained in:
@@ -3,7 +3,7 @@ use std::fmt;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
#[cfg(feature = "compat")]
|
||||
use http_types;
|
||||
use http;
|
||||
|
||||
/// An HTTP status code (`status-code` in RFC 7230 et al.).
|
||||
///
|
||||
@@ -600,17 +600,17 @@ impl From<StatusCode> for u16 {
|
||||
}
|
||||
|
||||
#[cfg(feature = "compat")]
|
||||
impl From<http_types::StatusCode> for StatusCode {
|
||||
fn from(status: http_types::StatusCode) -> StatusCode {
|
||||
impl From<http::StatusCode> for StatusCode {
|
||||
fn from(status: http::StatusCode) -> StatusCode {
|
||||
StatusCode::try_from(status.as_u16())
|
||||
.expect("attempted to convert invalid status code")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "compat")]
|
||||
impl From<StatusCode> for http_types::StatusCode {
|
||||
fn from(status: StatusCode) -> http_types::StatusCode {
|
||||
http_types::StatusCode::from_u16(status.as_u16())
|
||||
impl From<StatusCode> for http::StatusCode {
|
||||
fn from(status: StatusCode) -> http::StatusCode {
|
||||
http::StatusCode::from_u16(status.as_u16())
|
||||
.expect("attempted to convert invalid status code")
|
||||
}
|
||||
}
|
||||
@@ -769,12 +769,12 @@ mod tests {
|
||||
#[test]
|
||||
#[cfg(feature = "compat")]
|
||||
fn test_compat() {
|
||||
use http_types::{self, HttpTryFrom};
|
||||
use http::{self, HttpTryFrom};
|
||||
for i in 100..600 {
|
||||
let orig_hyper_status = StatusCode::try_from(i).unwrap();
|
||||
let orig_http_status = http_types::StatusCode::try_from(i).unwrap();
|
||||
let orig_http_status = http::StatusCode::try_from(i).unwrap();
|
||||
let conv_hyper_status: StatusCode = orig_http_status.into();
|
||||
let conv_http_status: http_types::StatusCode = orig_hyper_status.into();
|
||||
let conv_http_status: http::StatusCode = orig_hyper_status.into();
|
||||
assert_eq!(orig_hyper_status, conv_hyper_status);
|
||||
assert_eq!(orig_http_status, conv_http_status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user