From 0edb02595ca216443930816851543fa2620aba9c Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 17 May 2024 14:24:19 +1000 Subject: [PATCH] Use unwrap_or_else Clippy emits: warning: use of `expect` followed by a function call As suggested, use `unwrap_or_else` instead. --- integration_test/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_test/src/main.rs b/integration_test/src/main.rs index 687c4b5..500f3a4 100644 --- a/integration_test/src/main.rs +++ b/integration_test/src/main.rs @@ -50,8 +50,8 @@ fn get_rpc_url() -> String { fn get_auth() -> (String, Option) { if let Ok(cookie) = std::env::var("RPC_COOKIE") { - let contents = - fs::read_to_string(&cookie).expect(&format!("failed to read cookie file: {}", cookie)); + let contents = fs::read_to_string(&cookie) + .unwrap_or_else(|_| panic!("failed to read cookie file: {}", cookie)); let mut split = contents.split(':'); let user = split.next().expect("failed to get username from cookie file"); let pass = split.next().map_or("".to_string(), |s| s.to_string());