Refactoring not done yet, still need to do RSassert

This commit is contained in:
elvis
2025-08-24 02:01:24 +02:00
parent 8a492c7b8a
commit 3a4c4d43c2
18 changed files with 705 additions and 747 deletions

View File

@ -7,7 +7,7 @@ use super::choices::Choices;
use super::process::Process;
use super::reaction::Reaction;
use super::set::Set;
use super::translator::IdType;
use super::translator::{IdType, Translator, PrintableWithTranslator, Formatter};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Environment {
@ -154,6 +154,33 @@ impl From<Vec<(IdType, Process)>> for Environment {
}
}
impl PrintableWithTranslator for Environment {
fn print(&self, f: &mut std::fmt::Formatter, translator: &Translator)
-> std::fmt::Result {
write!(f, "{{env:")?;
let mut it = self.iter().peekable();
while let Some(el) = it.next() {
if it.peek().is_none() {
write!(
f,
"({} -> {})",
translator.decode(*el.0).unwrap_or("Missing".into()),
Formatter::from(translator, el.1)
)?;
} else {
write!(
f,
"({} -> {}), ",
translator.decode(*el.0).unwrap_or("Missing".into()),
Formatter::from(translator, el.1)
)?;
}
}
write!(f, "}}")
}
}
// -----------------------------------------------------------------------------
// Loops
// -----------------------------------------------------------------------------