Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl Display for BddVariableSet in the same way like BddValuation #55

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Display for BddVariableSet {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
if self.var_names.is_empty() {
write!(f, "[]")?;

Check warning on line 332 in src/_impl_bdd_variable_set.rs

View check run for this annotation

Codecov / codecov/patch

src/_impl_bdd_variable_set.rs#L330-L332

Added lines #L330 - L332 were not covered by tests
} else {
write!(f, "[{}", self.var_names[0])?;
for i in 1..self.var_names.len() {
write!(f, ",{}", self.var_names[i])?

Check warning on line 336 in src/_impl_bdd_variable_set.rs

View check run for this annotation

Codecov / codecov/patch

src/_impl_bdd_variable_set.rs#L334-L336

Added lines #L334 - L336 were not covered by tests
}
write!(f, "]")?;

Check warning on line 338 in src/_impl_bdd_variable_set.rs

View check run for this annotation

Codecov / codecov/patch

src/_impl_bdd_variable_set.rs#L338

Added line #L338 was not covered by tests
}
Ok(())

Check warning on line 340 in src/_impl_bdd_variable_set.rs

View check run for this annotation

Codecov / codecov/patch

src/_impl_bdd_variable_set.rs#L340

Added line #L340 was not covered by tests
}
}

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