]> git.lizzy.rs Git - rust.git/commitdiff
Filter packages only when '-p' was passed
authortopecongiro <seuchida@gmail.com>
Sat, 28 Oct 2017 15:13:37 +0000 (00:13 +0900)
committertopecongiro <seuchida@gmail.com>
Sat, 28 Oct 2017 15:13:37 +0000 (00:13 +0900)
src/bin/cargo-fmt.rs

index 3caf5522948d71ca9600f6ead95a82da14b2ad76..2c0b964b001e952f6c34d6117a93c2c87ab30f09 100644 (file)
@@ -261,12 +261,12 @@ fn filter_packages_with_hitlist<'a>(
     packages: Vec<Value>,
     workspace_hitlist: &'a WorkspaceHitlist,
 ) -> Result<Vec<Value>, &'a String> {
-    if *workspace_hitlist == WorkspaceHitlist::All {
+    let some_hitlist: Option<HashSet<&String>> =
+        workspace_hitlist.get_some().map(HashSet::from_iter);
+    if some_hitlist.is_none() {
         return Ok(packages);
     }
-    let mut hitlist: HashSet<&String> = workspace_hitlist
-        .get_some()
-        .map_or(HashSet::new(), HashSet::from_iter);
+    let mut hitlist = some_hitlist.unwrap();
     let members: Vec<Value> = packages
         .into_iter()
         .filter(|member| {