1
use std::fmt;
2

            
3
use itertools::Itertools;
4
use oxidd::bdd::BDDFunction;
5
use oxidd::util::OptBool;
6

            
7
use crate::CubeIter;
8

            
9
/// A helper structure to format configuration sets for output.
10
pub struct FormatConfigSet<'a>(pub &'a BDDFunction);
11

            
12
impl fmt::Display for FormatConfigSet<'_> {
13
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14
        write!(
15
            f,
16
            "{}",
17
            CubeIter::new(self.0).format_with("+", |cube, fmt| { fmt(&format_args!("{}", FormatConfig(&cube))) })
18
        )
19
    }
20
}
21

            
22
/// A helper structure to format a configuration for output.
23
pub struct FormatConfig<'a>(pub &'a Vec<OptBool>);
24

            
25
impl fmt::Display for FormatConfig<'_> {
26
3390
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27
16950
        for value in self.0 {
28
16950
            match value {
29
8541
                OptBool::True => write!(f, "1")?,
30
8234
                OptBool::False => write!(f, "0")?,
31
175
                OptBool::None => write!(f, "-")?,
32
            }
33
        }
34

            
35
3390
        Ok(())
36
3390
    }
37
}