Skip to content

Commit

Permalink
Convenience constructors for BddVariableSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Nov 24, 2023
1 parent 4887da0 commit fba442f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/_impl_bdd_variable_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,28 @@ impl BddVariableSet {
}
}

impl FromIterator<String> for BddVariableSet {
fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self {
let mut builder = BddVariableSetBuilder::new();
for var_name in iter {
builder.make_variable(var_name.as_str());
}
builder.build()
}
}

impl From<Vec<String>> for BddVariableSet {
fn from(value: Vec<String>) -> Self {
BddVariableSet::from_iter(value)
}
}

impl From<Vec<&str>> for BddVariableSet {
fn from(value: Vec<&str>) -> Self {
BddVariableSet::from_iter(value.iter().map(|it| it.to_string()))
}
}

#[cfg(test)]
mod tests {
use super::_test_util::mk_5_variable_set;
Expand Down

0 comments on commit fba442f

Please sign in to comment.