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