From 6a4ac8f3611f0b535623e13ca9fe782273d05bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Sun, 31 Jan 2021 21:12:00 +0100 Subject: [PATCH] matrix-sdk: Replace some unwraps with expects. --- matrix_sdk/src/http_client.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/matrix_sdk/src/http_client.rs b/matrix_sdk/src/http_client.rs index a13e2989..0b692856 100644 --- a/matrix_sdk/src/http_client.rs +++ b/matrix_sdk/src/http_client.rs @@ -182,7 +182,8 @@ pub(crate) fn client_with_config(config: &ClientConfig) -> Result a.clone(), - None => HeaderValue::from_str(&format!("matrix-rust-sdk {}", crate::VERSION)).unwrap(), + None => HeaderValue::from_str(&format!("matrix-rust-sdk {}", crate::VERSION)) + .expect("Can't construct the version header"), }; headers.insert(reqwest::header::USER_AGENT, user_agent); @@ -203,7 +204,9 @@ async fn response_to_http_response( let status = response.status(); let mut http_builder = HttpResponse::builder().status(status); - let headers = http_builder.headers_mut().unwrap(); + let headers = http_builder + .headers_mut() + .expect("Can't get the response builder headers"); for (k, v) in response.headers_mut().drain() { if let Some(key) = k { @@ -213,7 +216,9 @@ async fn response_to_http_response( let body = response.bytes().await?.as_ref().to_owned(); - Ok(http_builder.body(body).unwrap()) + Ok(http_builder + .body(body) + .expect("Can't construct a response using the given body")) } #[cfg(test)]