Skip to content

Commit

Permalink
Clippy suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Aug 12, 2024
1 parent 932984c commit 18d7dd5
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/_impl_bdd/_impl_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ mod tests {
// Missing zero.
assert!(Bdd::from_nodes(&nodes[1..]).is_err());
// Missing one.
assert!(Bdd::from_nodes(&vec![nodes[0].clone(), nodes[2].clone()]).is_err());
assert!(Bdd::from_nodes(&[nodes[0], nodes[2]]).is_err());

let mut nodes = bdd.clone().to_nodes();
nodes[0].var = BddVariable(1);
Expand Down Expand Up @@ -956,7 +956,7 @@ mod tests {
bdd.rename_variable(BddVariable(2), BddVariable(0));
bdd.rename_variable(BddVariable(3), BddVariable(4));
}
let expected = HashSet::from_iter(vec![BddVariable(0), BddVariable(4)].into_iter());
let expected = HashSet::from_iter(vec![BddVariable(0), BddVariable(4)]);
assert_eq!(expected, bdd.support_set());
}

Expand Down
18 changes: 6 additions & 12 deletions src/_impl_bdd_satisfying_valuations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,9 @@ mod tests {
expected.sort();

assert_eq!(sat_valuations.len(), 16);
sat_valuations
.into_iter()
.zip(expected.into_iter())
.for_each(|(a, b)| {
assert_eq!(a, b);
});
sat_valuations.into_iter().zip(expected).for_each(|(a, b)| {
assert_eq!(a, b);
});
}

#[test]
Expand All @@ -147,12 +144,9 @@ mod tests {
expected.sort();

assert_eq!(sat_valuations.len(), expected.len());
sat_valuations
.into_iter()
.zip(expected.into_iter())
.for_each(|(a, b)| {
assert_eq!(a, b);
});
sat_valuations.into_iter().zip(expected).for_each(|(a, b)| {
assert_eq!(a, b);
});
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions src/_impl_bdd_valuation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ mod tests {
let v1 = universe.mk_var_by_name("x_0");
let v2 = universe.mk_var_by_name("x_1");
let bdd = bdd!(v1 & (!v2));
assert_eq!(true, bdd.eval_in(&BddValuation::new(vec![true, false])));
assert_eq!(false, bdd.eval_in(&BddValuation::new(vec![true, true])));
assert_eq!(false, bdd.eval_in(&BddValuation::new(vec![false, false])));
assert_eq!(false, bdd.eval_in(&BddValuation::new(vec![false, false])));
assert!(bdd.eval_in(&BddValuation::new(vec![true, false])));
assert!(!bdd.eval_in(&BddValuation::new(vec![true, true])));
assert!(!bdd.eval_in(&BddValuation::new(vec![false, false])));
assert!(!bdd.eval_in(&BddValuation::new(vec![false, false])));
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions src/_test_bdd/_test_bdd_logic_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ use crate::_test_util::{mk_5_variable_set, mk_small_test_bdd};
use crate::*;

fn v1() -> BddVariable {
return BddVariable(0);
BddVariable(0)
}
fn v2() -> BddVariable {
return BddVariable(1);
BddVariable(1)
}
fn v3() -> BddVariable {
return BddVariable(2);
BddVariable(2)
}
fn v4() -> BddVariable {
return BddVariable(3);
BddVariable(3)
}

#[test]
Expand Down
20 changes: 10 additions & 10 deletions src/_test_bdd/_test_bdd_logic_fuzzing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ impl BddOpTree {
})
.collect();
levels.push(level);
level_width = level_width / 2;
level_width /= 2;
}

return BddOpTree {
BddOpTree {
leaves,
ops: levels,
};
}
}

/// Evaluate this op tree to `Bdd` using the given `BddVariableSet`.
Expand All @@ -94,11 +94,11 @@ impl BddOpTree {
let b = &formulas[i + 1];
let op = &level[i / 2];
let result = match op.op {
BddOp::AND => a.and(&b),
BddOp::OR => a.or(&b),
BddOp::XOR => a.xor(&b),
BddOp::IMP => a.imp(&b),
BddOp::IFF => a.iff(&b),
BddOp::AND => a.and(b),
BddOp::OR => a.or(b),
BddOp::XOR => a.xor(b),
BddOp::IMP => a.imp(b),
BddOp::IFF => a.iff(b),
};
if op.negate {
new_formulas.push(result.not())
Expand All @@ -110,7 +110,7 @@ impl BddOpTree {
formulas = new_formulas;
}

return formulas[0].clone();
formulas[0].clone()
}

/// Evaluate this op tree with the specified `BddValuation`.
Expand Down Expand Up @@ -141,7 +141,7 @@ impl BddOpTree {
values = new_values;
}

return values[0];
values[0]
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/_test_bdd/_test_bdd_ops_with_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use crate::op_function::and;
use crate::{bdd, Bdd, BddVariable};

fn v1() -> BddVariable {
return BddVariable(0);
BddVariable(0)
}
fn v2() -> BddVariable {
return BddVariable(1);
BddVariable(1)
}
fn v3() -> BddVariable {
return BddVariable(2);
BddVariable(2)
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/_test_bdd/_test_bdd_relation_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ fn vars() -> (
BddVariable,
BddVariable,
) {
return (
(
BddVariable(0),
BddVariable(1),
BddVariable(2),
BddVariable(3),
BddVariable(4),
);
)
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/_test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn mk_small_test_bdd() -> Bdd {
BddPointer::zero(),
bdd.root_pointer(),
));
return bdd;
bdd
}

/// Make a new `BddVariableSet` with variables $v_1, v_2, v_3, v_4, v_5$.
Expand All @@ -22,6 +22,6 @@ pub fn mk_5_variable_set() -> BddVariableSet {
}

pub fn load_expected_results(test_name: &str) -> String {
return std::fs::read_to_string(format!("res/test_results/{}", test_name))
.expect("Cannot open result file.");
std::fs::read_to_string(format!("res/test_results/{}", test_name))
.expect("Cannot open result file.")
}
10 changes: 5 additions & 5 deletions src/tutorial/p05_bdd_valuations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
//! some of the following methods to obtain some insight into the structure of the `Bdd`:
//!
//! - `Bdd.first_valuation` and `Bdd.last_valuation` will give you the (lexicographically) first
//! and last valuation.
//! and last valuation.
//! - Similarly, `Bdd.first_clause` and `Bdd.last_clause` will give you the first and last path
//! satisfying path.
//! satisfying path.
//! - `Bdd.most_positive_valuation` and `Bdd.most_negative_valuation` return the valuations
//! with the highest amount of positive/negative literals.
//! with the highest amount of positive/negative literals.
//! - `Bdd.most_fixed_clause` and `Bdd.most_free_clause` wil give you satisfying paths with
//! greatest and least amount of fixed variables respectively.
//! greatest and least amount of fixed variables respectively.
//! - `Bdd.random_valuation` and `Bdd.random_clause` allow selecting valuation/clause using
//! a random number generator.
//! a random number generator.
//!
//!

0 comments on commit 18d7dd5

Please sign in to comment.