[PATCH 2 of 2] rust-discovery: use while loop instead of match + break

Yuya Nishihara yuya at tcha.org
Fri Aug 16 07:28:12 EDT 2019


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1565948045 -32400
#      Fri Aug 16 18:34:05 2019 +0900
# Node ID 7c07a39ae2557c7a41a56ff2552ae635b8c5d880
# Parent  efcd5928d84224dea38b08d1dc1e135b91e0c045
rust-discovery: use while loop instead of match + break

This looks slightly nicer.

diff --git a/rust/hg-core/src/discovery.rs b/rust/hg-core/src/discovery.rs
--- a/rust/hg-core/src/discovery.rs
+++ b/rust/hg-core/src/discovery.rs
@@ -65,13 +65,7 @@ where
     let mut visit: VecDeque<Revision> = heads.into_iter().collect();
     let mut factor: u32 = 1;
     let mut seen: HashSet<Revision> = HashSet::new();
-    loop {
-        let current = match visit.pop_front() {
-            None => {
-                break;
-            }
-            Some(r) => r,
-        };
+    while let Some(current) = visit.pop_front() {
         if !seen.insert(current) {
             continue;
         }


More information about the Mercurial-devel mailing list