diff --git a/crates/pindakaas/src/lib.rs b/crates/pindakaas/src/lib.rs index a7915ce73..4ce02e773 100755 --- a/crates/pindakaas/src/lib.rs +++ b/crates/pindakaas/src/lib.rs @@ -564,7 +564,7 @@ enum Dimacs { Wcnf(Wcnf), } -fn parse_dimacs_file(path: &Path, expect_wcnf: bool) -> Result { +fn parse_dimacs_file(path: &Path) -> Result { let file = File::open(path)?; let mut had_header = false; @@ -579,7 +579,7 @@ fn parse_dimacs_file(path: &Path, expect_wcnf: bool) -> Result (), Ok(line) if had_header => { for seg in line.split(' ') { - if expect_wcnf { + if WEIGHTED { if let Ok(weight) = seg.parse::() { wcnf.weights.push(match weight.cmp(&top.unwrap()) { Ordering::Less => Some(weight), @@ -607,12 +607,12 @@ fn parse_dimacs_file(path: &Path, expect_wcnf: bool) -> Result { let vec: Vec<&str> = line.split_whitespace().collect(); // check "p" and "cnf" keyword - if !expect_wcnf && (vec.len() != 4 || vec[0..2] != ["p", "cnf"]) { + if !WEIGHTED && (vec.len() != 4 || vec[0..2] != ["p", "cnf"]) { return Err(io::Error::new( io::ErrorKind::InvalidInput, "expected DIMACS CNF header formatted \"p cnf {variables} {clauses}\"", )); - } else if expect_wcnf && (vec.len() != 4 || vec[0..2] != ["p", "wcnf"]) { + } else if WEIGHTED && (vec.len() != 4 || vec[0..2] != ["p", "wcnf"]) { return Err(io::Error::new( io::ErrorKind::InvalidInput, "expected DIMACS WCNF header formatted \"p wcnf {variables} {clauses} {top}\"", @@ -638,7 +638,7 @@ fn parse_dimacs_file(path: &Path, expect_wcnf: bool) -> Result Result Result Result { - match parse_dimacs_file(path, false)? { + match parse_dimacs_file::(path)? { Dimacs::Cnf(cnf) => Ok(cnf), _ => unreachable!(), } @@ -671,7 +671,7 @@ impl Cnf { impl Wcnf { /// Read a WCNF formula from a file formatted in the (W)DIMACS WCNF format pub fn from_file(path: &Path) -> Result { - match parse_dimacs_file(path, true)? { + match parse_dimacs_file::(path)? { Dimacs::Wcnf(wcnf) => Ok(wcnf), _ => unreachable!(), }