mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2025-01-06 13:28:39 +00:00
use expect
This commit is contained in:
parent
88d999a6b5
commit
ca9a8c358a
2 changed files with 7 additions and 5 deletions
|
@ -1,9 +1,9 @@
|
||||||
#![allow(clippy::unwrap_used)]
|
//! Remove these conversion helpers after actix-web upgrades to http 1.0
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
pub fn header_value(v: &http02::HeaderValue) -> http::HeaderValue {
|
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
|
pub fn header_map<'a, H>(m: H) -> http::HeaderMap
|
||||||
|
@ -13,7 +13,8 @@ where
|
||||||
let mut new_map = http::HeaderMap::new();
|
let mut new_map = http::HeaderMap::new();
|
||||||
for (n, v) in m {
|
for (n, v) in m {
|
||||||
new_map.insert(
|
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),
|
header_value(v),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,9 +22,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn method(m: &http02::Method) -> http::Method {
|
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 {
|
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")
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ mod test {
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
/// Remove this conversion helper after actix-web upgrades to http 1.0
|
||||||
fn header_pair(
|
fn header_pair(
|
||||||
p: (&http::HeaderName, &http::HeaderValue),
|
p: (&http::HeaderName, &http::HeaderValue),
|
||||||
) -> (http02::HeaderName, http02::HeaderValue) {
|
) -> (http02::HeaderName, http02::HeaderValue) {
|
||||||
|
|
Loading…
Reference in a new issue