diff --git a/crates/cheatcodes/src/fs.rs b/crates/cheatcodes/src/fs.rs index 129f8a22e939..177037c905b6 100644 --- a/crates/cheatcodes/src/fs.rs +++ b/crates/cheatcodes/src/fs.rs @@ -387,10 +387,10 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result>(); - let artifact = match filtered.len() { - 0 => Err(fmt_err!("No matching artifact found")), - 1 => Ok(filtered[0]), - _ => { + let artifact = match &filtered[..] { + [] => Err(fmt_err!("No matching artifact found")), + [artifact] => Ok(artifact), + filtered => { // If we know the current script/test contract solc version, try to filter by it state .config @@ -398,11 +398,10 @@ fn get_artifact_code(state: &Cheatcodes, path: &str, deployed: bool) -> Result>(); - - (filtered.len() == 1).then_some(filtered[0]) + (filtered.len() == 1).then(|| filtered[0]) }) .ok_or_else(|| fmt_err!("Multiple matching artifacts found")) }