Skip to content

Commit

Permalink
Prefer unwrap_or_else()
Browse files Browse the repository at this point in the history
  • Loading branch information
Utagai committed Oct 16, 2020
1 parent 252dea5 commit 7a10957
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/handlers/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn spotify_resource_id(base: &str, uri: &str, sep: &str, resource_type: &str) ->
let id_string_with_query_params = uri.trim_start_matches(&uri_prefix);
let query_idx = id_string_with_query_params
.find('?')
.unwrap_or(id_string_with_query_params.len());
.unwrap_or_else(|| id_string_with_query_params.len());
let id_string = id_string_with_query_params[0..query_idx].to_string();
// If the lengths aren't equal, we must have found a match.
let matched = id_string_with_query_params.len() != uri.len() && id_string.len() != uri.len();
Expand Down

0 comments on commit 7a10957

Please sign in to comment.