Take advantage of match ergonomics

This commit is contained in:
Oliver Hamlet
2018-10-06 16:26:18 +01:00
parent d3f4169d76
commit 2bb3d8b26f
2 changed files with 13 additions and 13 deletions
+9 -9
View File
@@ -201,15 +201,15 @@ impl Function {
}
}
let result = match *self {
Function::FilePath(ref f) => evaluate_file_path(state, f),
Function::FileRegex(ref p, ref r) => evaluate_file_regex(state, p, r),
Function::ActivePath(ref p) => evaluate_active_path(state, p),
Function::ActiveRegex(ref r) => evaluate_active_regex(state, r),
Function::Many(ref p, ref r) => evaluate_many(state, p, r),
Function::ManyActive(ref r) => evaluate_many_active(state, r),
Function::Checksum(ref path, ref crc) => evaluate_checksum(state, path, *crc),
Function::Version(ref p, ref v, ref c) => evaluate_version(state, p, v, *c),
let result = match self {
Function::FilePath(f) => evaluate_file_path(state, f),
Function::FileRegex(p, r) => evaluate_file_regex(state, p, r),
Function::ActivePath(p) => evaluate_active_path(state, p),
Function::ActiveRegex(r) => evaluate_active_regex(state, r),
Function::Many(p, r) => evaluate_many(state, p, r),
Function::ManyActive(r) => evaluate_many_active(state, r),
Function::Checksum(path, crc) => evaluate_checksum(state, path, *crc),
Function::Version(p, v, c) => evaluate_version(state, p, v, *c),
};
if self.is_slow() {
+4 -4
View File
@@ -234,10 +234,10 @@ enum Condition {
impl Condition {
fn eval(&self, state: &State) -> Result<bool, Error> {
match *self {
Condition::Function(ref f) => f.eval(state),
Condition::InvertedFunction(ref f) => f.eval(state).map(|r| !r),
Condition::Expression(ref e) => e.eval(state),
match self {
Condition::Function(f) => f.eval(state),
Condition::InvertedFunction(f) => f.eval(state).map(|r| !r),
Condition::Expression(e) => e.eval(state),
}
}