Run rustfmt (Rust 1.31.1)

This commit is contained in:
Oliver Hamlet
2018-12-22 22:50:16 +00:00
parent 5e1ba5709b
commit 9ef82fe886
6 changed files with 128 additions and 106 deletions
+10 -5
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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);
+76 -74
View File
@@ -15,13 +15,14 @@ impl ComparisonOperator {
input, input,
operator: operator:
alt!( alt!(
tag!("==") => { |_| ComparisonOperator::Equal } | tag!("==") => { |_| ComparisonOperator::Equal } |
tag!("!=") => { |_| ComparisonOperator::NotEqual } | tag!("!=") => { |_| ComparisonOperator::NotEqual } |
tag!("<=") => { |_| ComparisonOperator::LessThanOrEqual } | tag!("<=") => { |_| ComparisonOperator::LessThanOrEqual } |
tag!(">=") => { |_| ComparisonOperator::GreaterThanOrEqual } | tag!(">=") => { |_| ComparisonOperator::GreaterThanOrEqual } |
tag!("<") => { |_| ComparisonOperator::LessThan } | tag!("<") => { |_| ComparisonOperator::LessThan } |
tag!(">") => { |_| ComparisonOperator::GreaterThan } tag!(">") => { |_| ComparisonOperator::GreaterThan }
) >> (operator) )
>> (operator)
) )
} }
} }
@@ -180,74 +181,75 @@ impl Function {
input, input,
function: function:
alt!( alt!(
delimited!( delimited!(
fix_error!(ParsingError, tag!("file(\"")), fix_error!(ParsingError, tag!("file(\"")),
call!(parse_non_regex_path), call!(parse_non_regex_path),
fix_error!(ParsingError, tag!("\")")) fix_error!(ParsingError, tag!("\")"))
) => { ) => {
|path| Function::FilePath(path) |path| Function::FilePath(path)
} | } |
delimited!( delimited!(
fix_error!(ParsingError, tag!("file(\"")), fix_error!(ParsingError, tag!("file(\"")),
call!(parse_regex_path), call!(parse_regex_path),
fix_error!(ParsingError, tag!("\"")) fix_error!(ParsingError, tag!("\""))
) => { ) => {
|(p, r)| Function::FileRegex(p, r) |(p, r)| Function::FileRegex(p, r)
} | } |
delimited!( delimited!(
fix_error!(ParsingError, tag!("active(\"")), fix_error!(ParsingError, tag!("active(\"")),
call!(parse_non_regex_path), call!(parse_non_regex_path),
fix_error!(ParsingError, tag!("\")")) fix_error!(ParsingError, tag!("\")"))
) => { ) => {
|path| Function::ActivePath(path) |path| Function::ActivePath(path)
} | } |
delimited!( delimited!(
fix_error!(ParsingError, tag!("active(\"")), fix_error!(ParsingError, tag!("active(\"")),
flat_map!(fix_error!(ParsingError, is_not!(INVALID_REGEX_PATH_CHARS)), parse_regex), flat_map!(fix_error!(ParsingError, is_not!(INVALID_REGEX_PATH_CHARS)), parse_regex),
fix_error!(ParsingError, tag!("\"")) fix_error!(ParsingError, tag!("\""))
) => { ) => {
|r| Function::ActiveRegex(r) |r| Function::ActiveRegex(r)
} | } |
delimited!( delimited!(
fix_error!(ParsingError, tag!("many(\"")), fix_error!(ParsingError, tag!("many(\"")),
call!(parse_regex_path), call!(parse_regex_path),
fix_error!(ParsingError, tag!("\"")) fix_error!(ParsingError, tag!("\""))
) => { ) => {
|(p, r)| Function::Many(p, r) |(p, r)| Function::Many(p, r)
} | } |
delimited!( delimited!(
fix_error!(ParsingError, tag!("many_active(\"")), fix_error!(ParsingError, tag!("many_active(\"")),
flat_map!(fix_error!(ParsingError, is_not!(INVALID_REGEX_PATH_CHARS)), parse_regex), flat_map!(fix_error!(ParsingError, is_not!(INVALID_REGEX_PATH_CHARS)), parse_regex),
fix_error!(ParsingError, tag!("\"")) fix_error!(ParsingError, tag!("\""))
) => { ) => {
|r| Function::ManyActive(r) |r| Function::ManyActive(r)
} | } |
delimited!( delimited!(
fix_error!(ParsingError, tag!("version(")), fix_error!(ParsingError, tag!("version(")),
call!(parse_version_args), call!(parse_version_args),
fix_error!(ParsingError, tag!(")")) fix_error!(ParsingError, tag!(")"))
) => { ) => {
|(path, version, comparator)| { |(path, version, comparator)| {
Function::Version(path, version, comparator) Function::Version(path, version, comparator)
}
} |
delimited!(
fix_error!(ParsingError, tag!("product_version(")),
call!(parse_version_args),
fix_error!(ParsingError, tag!(")"))
) => {
|(path, version, comparator)| {
Function::ProductVersion(path, version, comparator)
}
} |
delimited!(
fix_error!(ParsingError, tag!("checksum(")),
call!(parse_checksum_args),
fix_error!(ParsingError, tag!(")"))
) => {
|(path, crc)| Function::Checksum(path, crc)
} }
} | )
delimited!( >> (function)
fix_error!(ParsingError, tag!("product_version(")),
call!(parse_version_args),
fix_error!(ParsingError, tag!(")"))
) => {
|(path, version, comparator)| {
Function::ProductVersion(path, version, comparator)
}
} |
delimited!(
fix_error!(ParsingError, tag!("checksum(")),
call!(parse_checksum_args),
fix_error!(ParsingError, tag!(")"))
) => {
|(path, crc)| Function::Checksum(path, crc)
}
) >> (function)
) )
} }
} }
+13 -12
View File
@@ -237,16 +237,17 @@ impl Condition {
input, input,
condition: condition:
alt!( alt!(
call!(Function::parse) => { call!(Function::parse) => {
|f| Condition::Function(f) |f| Condition::Function(f)
} | } |
preceded!(fix_error!(ParsingError, ws!(tag!("not"))), call!(Function::parse)) => { preceded!(fix_error!(ParsingError, ws!(tag!("not"))), call!(Function::parse)) => {
|f| Condition::InvertedFunction(f) |f| Condition::InvertedFunction(f)
} | } |
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));