use expect

This commit is contained in:
Felix Ableitner 2024-09-11 14:38:05 +02:00
parent 88d999a6b5
commit ca9a8c358a
2 changed files with 7 additions and 5 deletions

View file

@ -1,9 +1,9 @@
#![allow(clippy::unwrap_used)]
//! Remove these conversion helpers after actix-web upgrades to http 1.0
use std::str::FromStr;
pub fn header_value(v: &http02::HeaderValue) -> http::HeaderValue {
http::HeaderValue::from_bytes(v.as_bytes()).unwrap()
http::HeaderValue::from_bytes(v.as_bytes()).expect("can convert http types")
}
pub fn header_map<'a, H>(m: H) -> http::HeaderMap
@ -13,7 +13,8 @@ where
let mut new_map = http::HeaderMap::new();
for (n, v) in m {
new_map.insert(
http::HeaderName::from_lowercase(n.as_str().as_bytes()).unwrap(),
http::HeaderName::from_lowercase(n.as_str().as_bytes())
.expect("can convert http types"),
header_value(v),
);
}
@ -21,9 +22,9 @@ where
}
pub fn method(m: &http02::Method) -> http::Method {
http::Method::from_bytes(m.as_str().as_bytes()).unwrap()
http::Method::from_bytes(m.as_str().as_bytes()).expect("can convert http types")
}
pub fn uri(m: &http02::Uri) -> http::Uri {
http::Uri::from_str(&m.to_string()).unwrap()
http::Uri::from_str(&m.to_string()).expect("can convert http types")
}

View file

@ -64,6 +64,7 @@ mod test {
use serde_json::json;
use url::Url;
/// Remove this conversion helper after actix-web upgrades to http 1.0
fn header_pair(
p: (&http::HeaderName, &http::HeaderValue),
) -> (http02::HeaderName, http02::HeaderValue) {