use crate::{error::Result, CompilerInput, CompilerOutput, Solc}; /// The result of a `solc` process bundled with its `Solc` and `CompilerInput` type CompileElement = (Result, Solc, CompilerInput); /// The bundled output of multiple `solc` processes. #[derive(Debug)] pub struct CompiledMany { outputs: Vec, } impl CompiledMany { pub fn new(outputs: Vec) -> Self { Self { outputs } } /// Returns an iterator over all output elements pub fn outputs(&self) -> impl Iterator { self.outputs.iter() } /// Returns an iterator over all output elements pub fn into_outputs(self) -> impl Iterator { self.outputs.into_iter() } /// Returns all `CompilerOutput` or the first error that occurred pub fn flattened(self) -> Result> { self.into_iter().collect() } } impl IntoIterator for CompiledMany { type Item = Result; type IntoIter = std::vec::IntoIter>; fn into_iter(self) -> Self::IntoIter { self.outputs.into_iter().map(|(res, _, _)| res).collect::>().into_iter() } }