Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Use unwrap_or_else
Browse files Browse the repository at this point in the history
Clippy emits:

  warning: use of `expect` followed by a function call

As suggested, use `unwrap_or_else` instead.
  • Loading branch information
tcharding committed May 31, 2024
1 parent f33351d commit ac3fa84
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ fn get_rpc_url() -> String {

fn get_auth() -> (String, Option<String>) {
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());
Expand Down

0 comments on commit ac3fa84

Please sign in to comment.