mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Take advantage of match ergonomics
This commit is contained in:
@@ -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
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user