mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Run rustfmt (Rust 1.31.1)
This commit is contained in:
+10
-5
@@ -45,7 +45,8 @@ fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
GameType::Tes4,
|
GameType::Tes4,
|
||||||
"tests/testing-plugins/Oblivion/Data".into(),
|
"tests/testing-plugins/Oblivion/Data".into(),
|
||||||
".".into(),
|
".".into(),
|
||||||
).with_active_plugins(&generate_active_plugins());
|
)
|
||||||
|
.with_active_plugins(&generate_active_plugins());
|
||||||
|
|
||||||
let expression = Expression::from_str("active(\"Blank.esm\")").unwrap();
|
let expression = Expression::from_str("active(\"Blank.esm\")").unwrap();
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
GameType::Tes4,
|
GameType::Tes4,
|
||||||
"tests/testing-plugins/Oblivion/Data".into(),
|
"tests/testing-plugins/Oblivion/Data".into(),
|
||||||
".".into(),
|
".".into(),
|
||||||
).with_active_plugins(&generate_active_plugins());
|
)
|
||||||
|
.with_active_plugins(&generate_active_plugins());
|
||||||
|
|
||||||
let expression = Expression::from_str("active(\"Blank.*\")").unwrap();
|
let expression = Expression::from_str("active(\"Blank.*\")").unwrap();
|
||||||
|
|
||||||
@@ -82,7 +84,8 @@ fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
GameType::Tes4,
|
GameType::Tes4,
|
||||||
"tests/testing-plugins/Oblivion/Data".into(),
|
"tests/testing-plugins/Oblivion/Data".into(),
|
||||||
".".into(),
|
".".into(),
|
||||||
).with_active_plugins(&generate_active_plugins());
|
)
|
||||||
|
.with_active_plugins(&generate_active_plugins());
|
||||||
|
|
||||||
let expression = Expression::from_str("many_active(\"Blank.*\")").unwrap();
|
let expression = Expression::from_str("many_active(\"Blank.*\")").unwrap();
|
||||||
|
|
||||||
@@ -109,7 +112,8 @@ fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
GameType::Tes4,
|
GameType::Tes4,
|
||||||
"tests/testing-plugins/Oblivion/Data".into(),
|
"tests/testing-plugins/Oblivion/Data".into(),
|
||||||
".".into(),
|
".".into(),
|
||||||
).with_plugin_versions(&generate_plugin_versions());
|
)
|
||||||
|
.with_plugin_versions(&generate_plugin_versions());
|
||||||
|
|
||||||
let expression = Expression::from_str("version(\"Blank.esm\", \"5.0\", ==)").unwrap();
|
let expression = Expression::from_str("version(\"Blank.esm\", \"5.0\", ==)").unwrap();
|
||||||
|
|
||||||
@@ -122,7 +126,8 @@ fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
let state = State::new(GameType::Tes4, ".".into(), ".".into());
|
let state = State::new(GameType::Tes4, ".".into(), ".".into());
|
||||||
let expression = Expression::from_str(
|
let expression = Expression::from_str(
|
||||||
"version(\"tests/loot_api_win32/loot_api.dll\", \"0.13.8.0\", ==)",
|
"version(\"tests/loot_api_win32/loot_api.dll\", \"0.13.8.0\", ==)",
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
assert!(expression.eval(&state).unwrap());
|
assert!(expression.eval(&state).unwrap());
|
||||||
|
|||||||
+6
-3
@@ -38,7 +38,8 @@ pub unsafe extern "C" fn lci_condition_parse(condition: *const c_char) -> c_int
|
|||||||
LCI_OK
|
LCI_OK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).unwrap_or(LCI_ERROR_PANICKED)
|
})
|
||||||
|
.unwrap_or(LCI_ERROR_PANICKED)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -71,7 +72,8 @@ pub unsafe extern "C" fn lci_condition_eval(
|
|||||||
Err(e) => handle_error(e),
|
Err(e) => handle_error(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).unwrap_or(LCI_ERROR_PANICKED)
|
})
|
||||||
|
.unwrap_or(LCI_ERROR_PANICKED)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -90,5 +92,6 @@ pub unsafe extern "C" fn lci_get_error_message(message: *mut *const c_char) -> c
|
|||||||
|
|
||||||
LCI_OK
|
LCI_OK
|
||||||
}
|
}
|
||||||
}).unwrap_or(LCI_ERROR_PANICKED)
|
})
|
||||||
|
.unwrap_or(LCI_ERROR_PANICKED)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-5
@@ -61,7 +61,8 @@ pub unsafe extern "C" fn lci_state_create(
|
|||||||
|
|
||||||
LCI_OK
|
LCI_OK
|
||||||
}
|
}
|
||||||
}).unwrap_or(LCI_ERROR_PANICKED)
|
})
|
||||||
|
.unwrap_or(LCI_ERROR_PANICKED)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -105,7 +106,8 @@ pub unsafe extern "C" fn lci_state_set_active_plugins(
|
|||||||
|
|
||||||
LCI_OK
|
LCI_OK
|
||||||
}
|
}
|
||||||
}).unwrap_or(LCI_ERROR_PANICKED)
|
})
|
||||||
|
.unwrap_or(LCI_ERROR_PANICKED)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -142,7 +144,8 @@ pub unsafe extern "C" fn lci_state_set_plugin_versions(
|
|||||||
|
|
||||||
LCI_OK
|
LCI_OK
|
||||||
}
|
}
|
||||||
}).unwrap_or(LCI_ERROR_PANICKED)
|
})
|
||||||
|
.unwrap_or(LCI_ERROR_PANICKED)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -178,7 +181,8 @@ pub unsafe extern "C" fn lci_state_set_crc_cache(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).unwrap_or(LCI_ERROR_PANICKED)
|
})
|
||||||
|
.unwrap_or(LCI_ERROR_PANICKED)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -195,5 +199,6 @@ pub unsafe extern "C" fn lci_state_clear_condition_cache(state: *mut lci_state)
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).unwrap_or(LCI_ERROR_PANICKED)
|
})
|
||||||
|
.unwrap_or(LCI_ERROR_PANICKED)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-7
@@ -347,7 +347,8 @@ mod tests {
|
|||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esp"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esp"),
|
||||||
&state.data_path.join("Blank.esp.ghost"),
|
&state.data_path.join("Blank.esp.ghost"),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let function = Function::FilePath(PathBuf::from("Blank.esp"));
|
let function = Function::FilePath(PathBuf::from("Blank.esp"));
|
||||||
|
|
||||||
@@ -381,7 +382,8 @@ mod tests {
|
|||||||
copy(
|
copy(
|
||||||
Path::new("Cargo.toml"),
|
Path::new("Cargo.toml"),
|
||||||
&state.data_path.join("Cargo.toml.ghost"),
|
&state.data_path.join("Cargo.toml.ghost"),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let function = Function::FilePath(PathBuf::from("Cargo.toml"));
|
let function = Function::FilePath(PathBuf::from("Cargo.toml"));
|
||||||
|
|
||||||
@@ -535,7 +537,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_checksum_eval_should_be_false_if_the_file_checksum_does_not_equal_the_given_checksum(
|
fn function_checksum_eval_should_be_false_if_the_file_checksum_does_not_equal_the_given_checksum(
|
||||||
) {
|
) {
|
||||||
let function = Function::Checksum(
|
let function = Function::Checksum(
|
||||||
PathBuf::from("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
PathBuf::from("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
||||||
0xDEADBEEF,
|
0xDEADBEEF,
|
||||||
@@ -565,7 +567,8 @@ mod tests {
|
|||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
||||||
&state.data_path.join("Blank.esm.ghost"),
|
&state.data_path.join("Blank.esm.ghost"),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let function = Function::Checksum(PathBuf::from("Blank.esm"), 0x374E2A6F);
|
let function = Function::Checksum(PathBuf::from("Blank.esm"), 0x374E2A6F);
|
||||||
|
|
||||||
@@ -581,7 +584,8 @@ mod tests {
|
|||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.bsa"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.bsa"),
|
||||||
&state.data_path.join("Blank.bsa.ghost"),
|
&state.data_path.join("Blank.bsa.ghost"),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let function = Function::Checksum(PathBuf::from("Blank.bsa"), 0x22AB79D9);
|
let function = Function::Checksum(PathBuf::from("Blank.bsa"), 0x22AB79D9);
|
||||||
|
|
||||||
@@ -615,7 +619,8 @@ mod tests {
|
|||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
||||||
&state.data_path.join("Blank.esm"),
|
&state.data_path.join("Blank.esm"),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let function = Function::Checksum(PathBuf::from("Blank.esm"), 0x374E2A6F);
|
let function = Function::Checksum(PathBuf::from("Blank.esm"), 0x374E2A6F);
|
||||||
|
|
||||||
@@ -625,7 +630,8 @@ mod tests {
|
|||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.bsa"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.bsa"),
|
||||||
&state.data_path.join("Blank.esm"),
|
&state.data_path.join("Blank.esm"),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let function = Function::Checksum(PathBuf::from("Blank.esm"), 0x374E2A6F);
|
let function = Function::Checksum(PathBuf::from("Blank.esm"), 0x374E2A6F);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ impl ComparisonOperator {
|
|||||||
tag!(">=") => { |_| ComparisonOperator::GreaterThanOrEqual } |
|
tag!(">=") => { |_| ComparisonOperator::GreaterThanOrEqual } |
|
||||||
tag!("<") => { |_| ComparisonOperator::LessThan } |
|
tag!("<") => { |_| ComparisonOperator::LessThan } |
|
||||||
tag!(">") => { |_| ComparisonOperator::GreaterThan }
|
tag!(">") => { |_| ComparisonOperator::GreaterThan }
|
||||||
) >> (operator)
|
)
|
||||||
|
>> (operator)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,7 +248,8 @@ impl Function {
|
|||||||
) => {
|
) => {
|
||||||
|(path, crc)| Function::Checksum(path, crc)
|
|(path, crc)| Function::Checksum(path, crc)
|
||||||
}
|
}
|
||||||
) >> (function)
|
)
|
||||||
|
>> (function)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -246,7 +246,8 @@ impl Condition {
|
|||||||
delimited!(fix_error!(ParsingError, ws!(tag!("("))), call!(parse_expression), fix_error!(ParsingError, ws!(tag!(")")))) => {
|
delimited!(fix_error!(ParsingError, ws!(tag!("("))), call!(parse_expression), fix_error!(ParsingError, ws!(tag!(")")))) => {
|
||||||
|e| Condition::Expression(e)
|
|e| Condition::Expression(e)
|
||||||
}
|
}
|
||||||
) >> (condition)
|
)
|
||||||
|
>> (condition)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -380,7 +381,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn game_type_is_plugin_filename_should_be_true_for_esl_dot_ghost_for_tes5se_tes5vr_fo4_and_fo4vr(
|
fn game_type_is_plugin_filename_should_be_true_for_esl_dot_ghost_for_tes5se_tes5vr_fo4_and_fo4vr(
|
||||||
) {
|
) {
|
||||||
let filename = Path::new("Blank.esl.ghost");
|
let filename = Path::new("Blank.esl.ghost");
|
||||||
|
|
||||||
assert!(GameType::Tes5se.is_plugin_filename(filename));
|
assert!(GameType::Tes5se.is_plugin_filename(filename));
|
||||||
@@ -415,7 +416,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn game_type_is_plugin_filename_should_be_false_for_non_esp_esm_esl_dot_ghost_for_all_game_types(
|
fn game_type_is_plugin_filename_should_be_false_for_non_esp_esm_esl_dot_ghost_for_all_game_types(
|
||||||
) {
|
) {
|
||||||
let filename = Path::new("Blank.txt.ghost");
|
let filename = Path::new("Blank.txt.ghost");
|
||||||
|
|
||||||
assert!(!GameType::Tes4.is_plugin_filename(filename));
|
assert!(!GameType::Tes4.is_plugin_filename(filename));
|
||||||
|
|||||||
Reference in New Issue
Block a user