diff options
| author | Fuwn <[email protected]> | 2022-01-04 18:15:04 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-01-04 18:15:04 +0000 |
| commit | 8ed19aee8b0511475eb0f6f0001ead3848067b09 (patch) | |
| tree | d5a46a426e133ca60a6cfd8293ee809537114568 /src/utils.rs | |
| parent | feat(main.rs): ratelimit (100 requests/minute) (diff) | |
| download | api-worker-8ed19aee8b0511475eb0f6f0001ead3848067b09.tar.xz api-worker-8ed19aee8b0511475eb0f6f0001ead3848067b09.zip | |
chore: stricter clippy
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/utils.rs b/src/utils.rs index 275978d..a55ddc6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -6,6 +6,8 @@ use crate::{ structures::GitHubAPIResponse, }; +/// # Errors +/// if GitHub API is unresponsive pub async fn github_api() -> Result<GitHubAPIResponse, Box<dyn std::error::Error>> { let mut client = actix_web::client::Client::new() .get(GITHUB_API_ENDPOINT) @@ -33,10 +35,13 @@ pub async fn github_api() -> Result<GitHubAPIResponse, Box<dyn std::error::Error ) } +/// # Panics +/// if GitHub API is unresponsive pub async fn filter_languages() -> Vec<String> { let mut languages = vec![]; for i in github_api().await.unwrap().tree { + #[allow(clippy::used_underscore_binding)] if i._type == "tree" { languages.push(i.path); } @@ -45,6 +50,8 @@ pub async fn filter_languages() -> Vec<String> { languages } +/// # Panics +/// if GitHub API is unresponsive pub async fn filter_images_by_language(language: &str) -> Vec<String> { let mut images = vec![]; @@ -55,7 +62,7 @@ pub async fn filter_images_by_language(language: &str) -> Vec<String> { // TODO: Fix this with type_ascription let x: Vec<&str> = i.path.split('/').collect(); if x[0] == language && i.path.contains('/') { - images.push(format!("{}{}", GITHUB_USER_CONTENT, i.path)) + images.push(format!("{}{}", GITHUB_USER_CONTENT, i.path)); } } |