caustic/tooling/core/output/exit/
standard.rs1use super::super::super::{
4 conditions::{ExitCondition, ExitReason},
5 diagnostics::GlobalDiagnostics,
6};
7
8pub struct ExitEvaluator {
10 pub conditions: Vec<Box<dyn ExitCondition>>,
11 pub initial: GlobalDiagnostics,
12}
13
14impl ExitEvaluator {
15 pub fn new(initial: GlobalDiagnostics) -> Self {
16 Self {
17 conditions: vec![],
18 initial,
19 }
20 }
21
22 pub fn add_condition(&mut self, cond: Box<dyn ExitCondition>) {
23 self.conditions.push(cond);
24 }
25
26 pub fn check(&self, current: &GlobalDiagnostics) -> Option<ExitReason> {
28 self.conditions
29 .iter()
30 .find_map(|c| c.check(current, &self.initial))
31 }
32}