Skip to content

Commit

Permalink
fix: new clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Jan 27, 2023
1 parent badb791 commit e1765f3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
5 changes: 1 addition & 4 deletions src/apis/middlewares/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ pub async fn auth<B>(
where
B: Send,
{
let token = match params.token {
None => return AuthError::Unauthorized.into_response(),
Some(token) => token,
};
let Some(token) = params.token else { return AuthError::Unauthorized.into_response() };

if !authenticate(&token, &config.http_api) {
return AuthError::TokenNotValid.into_response();
Expand Down
3 changes: 1 addition & 2 deletions src/apis/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ pub fn ok_response() -> Response {
#[must_use]
pub fn invalid_info_hash_param_response(info_hash: &str) -> Response {
bad_request_response(&format!(
"Invalid URL: invalid infohash param: string \"{}\", expected a 40 character long string",
info_hash
"Invalid URL: invalid infohash param: string \"{info_hash}\", expected a 40 character long string"
))
}

Expand Down
9 changes: 3 additions & 6 deletions src/tracker/services/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,9 @@ pub async fn get_torrent_info(tracker: Arc<Tracker>, info_hash: &InfoHash) -> Op

let torrent_entry_option = db.get(info_hash);

let torrent_entry = match torrent_entry_option {
Some(torrent_entry) => torrent_entry,
None => {
return None;
}
};
let Some(torrent_entry) = torrent_entry_option else {
return None;
};

let (seeders, completed, leechers) = torrent_entry.get_stats();

Expand Down
5 changes: 1 addition & 4 deletions tests/api/asserts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ pub async fn assert_torrent_not_known(response: Response) {
pub async fn assert_invalid_infohash_param(response: Response, invalid_infohash: &str) {
assert_bad_request(
response,
&format!(
"Invalid URL: invalid infohash param: string \"{}\", expected a 40 character long string",
invalid_infohash
),
&format!("Invalid URL: invalid infohash param: string \"{invalid_infohash}\", expected a 40 character long string"),
)
.await;
}
Expand Down

0 comments on commit e1765f3

Please sign in to comment.