Skip to content

Commit

Permalink
Run Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bjgill committed Jun 21, 2018
1 parent cb5cb1b commit 616d354
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
12 changes: 9 additions & 3 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ fn merge_dependencies(old_dep: &mut toml_edit::Item, new: &Dependency) {
unreachable!("Invalid old dependency type");
}

if let Some(t) = old_dep.as_inline_table_mut() { t.fmt() }
if let Some(t) = old_dep.as_inline_table_mut() {
t.fmt()
}
}

/// Print a message if the new dependency version is different from the old one.
Expand Down Expand Up @@ -254,7 +256,9 @@ impl Manifest {
} else {
// update an existing entry
merge_dependencies(&mut table[&dep.name], dep);
if let Some(t) = table.as_inline_table_mut() { t.fmt() }
if let Some(t) = table.as_inline_table_mut() {
t.fmt()
}
}
Ok(())
}
Expand All @@ -276,7 +280,9 @@ impl Manifest {
}
if !dry_run {
merge_dependencies(&mut table[&dep.name], dep);
if let Some(t) = table.as_inline_table_mut() { t.fmt() }
if let Some(t) = table.as_inline_table_mut() {
t.fmt()
}
}
}

Expand Down
19 changes: 7 additions & 12 deletions tests/cargo-add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const BOGUS_CRATE_NAME: &str = "tests-will-break-if-there-is-ever-a-real-package
/// Check 'failure' deps are not present
fn no_manifest_failures(manifest: &toml_edit::Item) -> bool {
let no_failure_key_in = |section| manifest[section][BOGUS_CRATE_NAME].is_none();
no_failure_key_in("dependencies")
&& no_failure_key_in("dev-dependencies")
no_failure_key_in("dependencies") && no_failure_key_in("dev-dependencies")
&& no_failure_key_in("build-dependencies")
}

Expand Down Expand Up @@ -583,16 +582,12 @@ fn adds_multiple_optional_dependencies() {

// dependencies present afterwards
let toml = get_toml(&manifest);
assert!(
&toml["dependencies"]["my-package1"]["optional"]
.as_bool()
.expect("optional not a bool")
);
assert!(
&toml["dependencies"]["my-package2"]["optional"]
.as_bool()
.expect("optional not a bool")
);
assert!(&toml["dependencies"]["my-package1"]["optional"]
.as_bool()
.expect("optional not a bool"));
assert!(&toml["dependencies"]["my-package2"]["optional"]
.as_bool()
.expect("optional not a bool"));
}

#[test]
Expand Down

0 comments on commit 616d354

Please sign in to comment.