From 86044bc0c328bb0d7f420dbebd587b556bcb90f5 Mon Sep 17 00:00:00 2001 From: Bjerg Date: Fri, 7 Jan 2022 16:29:19 +0100 Subject: [PATCH] Add `ProjectCompileOutput::has_compiler_warnings` (#773) * Add `ProjectCompileOutput::has_compiler_warnings` * Nits --- ethers-solc/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ethers-solc/src/lib.rs b/ethers-solc/src/lib.rs index 78a77493..a573a3b7 100644 --- a/ethers-solc/src/lib.rs +++ b/ethers-solc/src/lib.rs @@ -774,11 +774,12 @@ impl ProjectCompileOutput { /// Whether there were errors pub fn has_compiler_errors(&self) -> bool { - if let Some(output) = self.compiler_output.as_ref() { - output.has_error() - } else { - false - } + self.compiler_output.as_ref().map(|o| o.has_error()).unwrap_or_default() + } + + /// Whether there were warnings + pub fn has_compiler_warnings(&self) -> bool { + self.compiler_output.as_ref().map(|o| o.has_warning()).unwrap_or_default() } /// Finds the first contract with the given name and removes it from the set