diff options
author | Cyborus <cyborus@noreply.codeberg.org> | 2024-08-11 17:29:43 +0200 |
---|---|---|
committer | Cyborus <cyborus@noreply.codeberg.org> | 2024-08-11 17:29:43 +0200 |
commit | a5fe0dfea83350713b797456c6373cc34aed9fa2 (patch) | |
tree | b05eb2a05e43c4317150134a2727bc39dffb870a | |
parent | Merge pull request 'bump version to 0.4.1' (#73) from bump-0.4.1 into main (diff) | |
parent | Clippy Fixes (diff) | |
download | forgejo-api-a5fe0dfea83350713b797456c6373cc34aed9fa2.tar.xz forgejo-api-a5fe0dfea83350713b797456c6373cc34aed9fa2.zip |
Merge pull request 'Clippy Fixes' (#74) from Pi-Cla/forgejo-api:clippy into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-api/pulls/74
Reviewed-by: Cyborus <cyborus@noreply.codeberg.org>
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | tests/admin.rs | 10 | ||||
-rw-r--r-- | tests/user.rs | 2 |
3 files changed, 5 insertions, 9 deletions
@@ -367,7 +367,7 @@ where { let list: Option<Vec<Option<structs::User>>> = Option::deserialize(deserializer).map_err(DE::custom)?; - Ok(list.map(|list| list.into_iter().filter_map(|x| x).collect::<Vec<_>>())) + Ok(list.map(|list| list.into_iter().flatten().collect::<Vec<_>>())) } fn parse_ssh_url(raw_url: &String) -> Result<Url, url::ParseError> { diff --git a/tests/admin.rs b/tests/admin.rs index 38d47ba..6b82fab 100644 --- a/tests/admin.rs +++ b/tests/admin.rs @@ -30,10 +30,7 @@ async fn user() { .await .expect("failed to search users"); assert!( - users - .iter() - .find(|u| u.login.as_ref().unwrap() == "Pipis") - .is_some(), + users.iter().any(|u| u.login.as_ref().unwrap() == "Pipis"), "could not find new user" ); let query = AdminGetAllEmailsQuery::default(); @@ -44,8 +41,7 @@ async fn user() { assert!( users .iter() - .find(|u| u.email.as_ref().unwrap() == "pipis@noreply.example.org") - .is_some(), + .any(|u| u.email.as_ref().unwrap() == "pipis@noreply.example.org"), "could not find new user" ); } @@ -153,7 +149,7 @@ async fn cron() { .admin_cron_list(query) .await .expect("failed to get crons list"); - api.admin_cron_run(&crons.get(0).expect("no crons").name.as_ref().unwrap()) + api.admin_cron_run(crons.first().expect("no crons").name.as_ref().unwrap()) .await .expect("failed to run cron"); } diff --git a/tests/user.rs b/tests/user.rs index 3b6e0e3..51e788a 100644 --- a/tests/user.rs +++ b/tests/user.rs @@ -164,7 +164,7 @@ async fn oauth2_login() { let code = code.unwrap(); // Redeem the code and check it works - let url = url::Url::parse(&base_url).unwrap(); + let url = url::Url::parse(base_url).unwrap(); let api = forgejo_api::Forgejo::new(forgejo_api::Auth::None, url.clone()).unwrap(); let request = forgejo_api::structs::OAuthTokenRequest::Confidential { |