jix / varisat

SAT solver written in Rust
https://jix.one/project/varisat
Apache License 2.0
253 stars 17 forks source link

Replace trival uses of match with matches! macro #164

Closed cjsauer closed 3 years ago

cjsauer commented 3 years ago

This is just some trivial code cleanups found by running the clippy lint tool. To repro:

rustup component add clippy
cargo clippy

which for me resulted in:

warning: drat-trim proof checker not found, some tests will be disabled: No such file or directory (os error 2)
warning: rate proof checker not found, some tests will be disabled: No such file or directory (os error 2)
warning: match expression looks like `matches!` macro
  --> varisat/varisat/src/solver.rs:48:9
   |
48 | /         match self {
49 | |             SolverError::Interrupted => true,
50 | |             _ => false,
51 | |         }
   | |_________^ help: try this: `matches!(self, SolverError::Interrupted)`
   |
   = note: `#[warn(clippy::match_like_matches_macro)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro

warning: match expression looks like `matches!` macro
   --> varisat/varisat/src/proof.rs:114:16
    |
114 |               || match self.format {
    |  ________________^
115 | |                 Some(ProofFormat::Varisat) => true,
116 | |                 _ => false,
117 | |             }
    | |_____________^ help: try this: `matches!(self.format, Some(ProofFormat::Varisat))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro

warning: match expression looks like `matches!` macro
  --> varisat/varisat/src/prop/graph.rs:37:9
   |
37 | /         match self {
38 | |             Reason::Unit => true,
39 | |             _ => false,
40 | |         }
   | |_________^ help: try this: `matches!(self, Reason::Unit)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro

warning: 3 warnings emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.05s

There were only 3 warnings, and they were all trivial uses of the match expression resulting in true/false, which can be more succinctly written using the matches! macro.