Skip to content

Commit

Permalink
Merge pull request #55 from zao111222333/master
Browse files Browse the repository at this point in the history
impl `Display` for `BddVariableSet` in the same way like `BddValuation`
  • Loading branch information
daemontus authored Aug 13, 2024
2 parents 58bd1df + cc0bf1e commit 6f0cfcf
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/_impl_bdd_variable_set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::*;
use std::convert::TryFrom;
use std::{
convert::TryFrom,
fmt::{Display, Formatter},
};

impl BddVariableSet {
/// Create a new `BddVariableSet` with anonymous variables $(x_0, \ldots, x_n)$ where $n$ is
Expand Down Expand Up @@ -323,6 +326,21 @@ impl BddVariableSet {
}
}

impl Display for BddVariableSet {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
if self.var_names.is_empty() {
write!(f, "[]")?;
} else {
write!(f, "[{}", self.var_names[0])?;
for i in 1..self.var_names.len() {
write!(f, ",{}", self.var_names[i])?
}
write!(f, "]")?;
}
Ok(())
}
}

impl FromIterator<String> for BddVariableSet {
fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self {
let mut builder = BddVariableSetBuilder::new();
Expand Down

0 comments on commit 6f0cfcf

Please sign in to comment.