foundry_compilers/compile/
many.rs1use foundry_compilers_artifacts::{CompilerOutput, SolcInput};
2use foundry_compilers_core::error::Result;
3
4use crate::compilers::solc::Solc;
5
6type CompileElement = (Result<CompilerOutput>, Solc, SolcInput);
8
9#[derive(Debug)]
11pub struct CompiledMany {
12 outputs: Vec<CompileElement>,
13}
14
15impl CompiledMany {
16 pub fn new(outputs: Vec<CompileElement>) -> Self {
17 Self { outputs }
18 }
19
20 pub fn outputs(&self) -> impl Iterator<Item = &CompileElement> {
22 self.outputs.iter()
23 }
24
25 pub fn into_outputs(self) -> impl Iterator<Item = CompileElement> {
27 self.outputs.into_iter()
28 }
29
30 pub fn flattened(self) -> Result<Vec<CompilerOutput>> {
32 self.into_iter().collect()
33 }
34}
35
36impl IntoIterator for CompiledMany {
37 type Item = Result<CompilerOutput>;
38 type IntoIter = std::vec::IntoIter<Result<CompilerOutput>>;
39
40 fn into_iter(self) -> Self::IntoIter {
41 self.outputs.into_iter().map(|(res, _, _)| res).collect::<Vec<_>>().into_iter()
42 }
43}