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 {
|
let result = match self {
|
||||||
Function::FilePath(ref f) => evaluate_file_path(state, f),
|
Function::FilePath(f) => evaluate_file_path(state, f),
|
||||||
Function::FileRegex(ref p, ref r) => evaluate_file_regex(state, p, r),
|
Function::FileRegex(p, r) => evaluate_file_regex(state, p, r),
|
||||||
Function::ActivePath(ref p) => evaluate_active_path(state, p),
|
Function::ActivePath(p) => evaluate_active_path(state, p),
|
||||||
Function::ActiveRegex(ref r) => evaluate_active_regex(state, r),
|
Function::ActiveRegex(r) => evaluate_active_regex(state, r),
|
||||||
Function::Many(ref p, ref r) => evaluate_many(state, p, r),
|
Function::Many(p, r) => evaluate_many(state, p, r),
|
||||||
Function::ManyActive(ref r) => evaluate_many_active(state, r),
|
Function::ManyActive(r) => evaluate_many_active(state, r),
|
||||||
Function::Checksum(ref path, ref crc) => evaluate_checksum(state, path, *crc),
|
Function::Checksum(path, crc) => evaluate_checksum(state, path, *crc),
|
||||||
Function::Version(ref p, ref v, ref c) => evaluate_version(state, p, v, *c),
|
Function::Version(p, v, c) => evaluate_version(state, p, v, *c),
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.is_slow() {
|
if self.is_slow() {
|
||||||
|
|||||||
+4
-4
@@ -234,10 +234,10 @@ enum Condition {
|
|||||||
|
|
||||||
impl Condition {
|
impl Condition {
|
||||||
fn eval(&self, state: &State) -> Result<bool, Error> {
|
fn eval(&self, state: &State) -> Result<bool, Error> {
|
||||||
match *self {
|
match self {
|
||||||
Condition::Function(ref f) => f.eval(state),
|
Condition::Function(f) => f.eval(state),
|
||||||
Condition::InvertedFunction(ref f) => f.eval(state).map(|r| !r),
|
Condition::InvertedFunction(f) => f.eval(state).map(|r| !r),
|
||||||
Condition::Expression(ref e) => e.eval(state),
|
Condition::Expression(e) => e.eval(state),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user