From ee0f82a0f23655245648ee8178839fc35d754f5c Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:08:40 -0500 Subject: [PATCH] Clippy updates --- cmd/soroban-cli/src/commands/contract/init.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/init.rs b/cmd/soroban-cli/src/commands/contract/init.rs index eed0570b5..ed34890d3 100644 --- a/cmd/soroban-cli/src/commands/contract/init.rs +++ b/cmd/soroban-cli/src/commands/contract/init.rs @@ -36,7 +36,7 @@ pub struct Cmd { fn possible_example_values() -> PossibleValuesParser { //TODO: handle this unwrap more gracefully let examples = get_valid_examples().unwrap(); - let parser = PossibleValuesParser::new(examples.iter().map(|s| PossibleValue::new(s))); + let parser = PossibleValuesParser::new(examples.iter().map(PossibleValue::new)); parser } @@ -54,18 +54,21 @@ struct ReqBody { } fn get_valid_examples() -> Result, Error> { - let body: ReqBody = ureq::get(GITHUB_API_URL).call()?.into_json()?; + let body: ReqBody = ureq::get(GITHUB_API_URL) + .call() + .map_err(Box::new)? + .into_json()?; let mut valid_examples = Vec::new(); for item in body.tree { if item.type_field == "blob" - || item.path.starts_with(".") - || item.path.contains("/") + || item.path.starts_with('.') + || item.path.contains('/') || item.path == "hello_world" { continue; - } else { - valid_examples.push(item.path); } + + valid_examples.push(item.path); } Ok(valid_examples) @@ -90,8 +93,8 @@ pub enum Error { #[error("Failed to parse Cargo.toml: {0}")] TomlParseError(#[from] TomlError), - #[error("Failed to fetch example contracts: {0}")] - ExampleContractFetchError(#[from] ureq::Error), + #[error("Failed to fetch example contracts")] + ExampleContractFetchError(#[from] Box), } impl Cmd {