diff --git a/examples/params.rs b/examples/params.rs index 8774046a67..0f26efb8bb 100644 --- a/examples/params.rs +++ b/examples/params.rs @@ -52,7 +52,7 @@ async fn param_example( return Ok(Response::builder() .status(StatusCode::UNPROCESSABLE_ENTITY) .body(full(MISSING)) - .unwrap()); + .expect("constant status won't error")); }; let number = if let Some(n) = params.get("number") { if let Ok(v) = n.parse::() { @@ -61,13 +61,13 @@ async fn param_example( return Ok(Response::builder() .status(StatusCode::UNPROCESSABLE_ENTITY) .body(full(NOTNUMERIC)) - .unwrap()); + .expect("constant status won't error")); } } else { return Ok(Response::builder() .status(StatusCode::UNPROCESSABLE_ENTITY) .body(full(MISSING)) - .unwrap()); + .expect("constant status won't error")); }; // Render the response. This will often involve @@ -86,7 +86,7 @@ async fn param_example( return Ok(Response::builder() .status(StatusCode::UNPROCESSABLE_ENTITY) .body(full(MISSING)) - .unwrap()); + .expect("constant status won't error")); }; let params = form_urlencoded::parse(query.as_bytes()) .into_owned() @@ -97,7 +97,7 @@ async fn param_example( return Ok(Response::builder() .status(StatusCode::UNPROCESSABLE_ENTITY) .body(full(MISSING)) - .unwrap()); + .expect("constant status won't error")); }; let body = format!("You requested {}", page); Ok(Response::new(full(body))) @@ -105,7 +105,7 @@ async fn param_example( _ => Ok(Response::builder() .status(StatusCode::NOT_FOUND) .body(empty()) - .unwrap()), + .expect("constant status won't error")), } } diff --git a/examples/send_file.rs b/examples/send_file.rs index b2ef328a1f..d3dc115a5d 100644 --- a/examples/send_file.rs +++ b/examples/send_file.rs @@ -61,7 +61,7 @@ fn not_found() -> Response> { Response::builder() .status(StatusCode::NOT_FOUND) .body(Full::new(NOTFOUND.into()).map_err(|e| match e {}).boxed()) - .unwrap() + .expect("constant status won't error") } async fn simple_file_send(filename: &str) -> Result>> { @@ -85,7 +85,7 @@ async fn simple_file_send(filename: &str) -> Result> for Svc { fn call(&self, req: Request) -> Self::Future { fn mk_response(s: String) -> Result>, hyper::Error> { - Ok(Response::builder().body(Full::new(Bytes::from(s))).unwrap()) + Ok(Response::new(Full::new(Bytes::from(s)))) } if req.uri().path() != "/favicon.ico" { diff --git a/examples/upgrades.rs b/examples/upgrades.rs index b94a8b9c42..b5460d96c9 100644 --- a/examples/upgrades.rs +++ b/examples/upgrades.rs @@ -100,7 +100,7 @@ async fn client_upgrade_request(addr: SocketAddr) -> Result<()> { .uri(format!("http://{}/", addr)) .header(UPGRADE, "foobar") .body(Empty::::new()) - .unwrap(); + .expect("uri/header parse won't error"); let stream = TcpStream::connect(addr).await?; let io = TokioIo::new(stream); diff --git a/examples/web_api.rs b/examples/web_api.rs index ffc62ba89b..ff2ea90b3d 100644 --- a/examples/web_api.rs +++ b/examples/web_api.rs @@ -29,7 +29,7 @@ async fn client_request_response() -> Result> { .uri(URL) .header(header::CONTENT_TYPE, "application/json") .body(Full::new(Bytes::from(POST_DATA))) - .unwrap(); + .expect("uri/header parse from constants won't error"); let host = req.uri().host().expect("uri has no host"); let port = req.uri().port_u16().expect("uri has no port"); @@ -73,11 +73,11 @@ async fn api_get_response() -> Result> { Ok(json) => Response::builder() .header(header::CONTENT_TYPE, "application/json") .body(full(json)) - .unwrap(), + .expect("header parse from constant won't error"), Err(_) => Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(full(INTERNAL_SERVER_ERROR)) - .unwrap(), + .expect("constant status won't error"), }; Ok(res) } @@ -93,7 +93,7 @@ async fn response_examples(req: Request) -> Result