]> git.proxmox.com Git - cargo.git/commitdiff
refactor: compare lockfile use Iterator.eq
authorWeihang Lo <me@weihanglo.tw>
Sun, 23 Aug 2020 01:07:54 +0000 (09:07 +0800)
committerWeihang Lo <me@weihanglo.tw>
Sun, 23 Aug 2020 01:07:54 +0000 (09:07 +0800)
src/cargo/ops/lockfile.rs

index 873fe0daaa0e2078c190c28d6706d8ddce2292a1..ea659c095e5edb1865b6640a5437276c5b94d3f5 100644 (file)
@@ -188,20 +188,7 @@ fn are_equal_lockfiles(orig: &str, current: &str, ws: &Workspace<'_>) -> bool {
         }
     }
 
-    let mut orig_iter = orig.lines();
-    let mut current_iter = current.lines();
-    loop {
-        match (orig_iter.next(), current_iter.next()) {
-            (Some(o), Some(c)) => {
-                if o != c {
-                    return false;
-                }
-            }
-            (Some(_), None) => return false,
-            (None, Some(_)) => return false,
-            (None, None) => return true,
-        }
-    }
+    orig.lines().eq(current.lines())
 }
 
 fn emit_package(dep: &toml::value::Table, out: &mut String) {