From patchwork Fri Aug 16 11:28:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,2] rust-discovery: use while loop instead of match + break From: Yuya Nishihara X-Patchwork-Id: 41315 Message-Id: <7c07a39ae2557c7a41a5.1565954892@mimosa> To: mercurial-devel@mercurial-scm.org Date: Fri, 16 Aug 2019 20:28:12 +0900 # HG changeset patch # User Yuya Nishihara # 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 = heads.into_iter().collect(); let mut factor: u32 = 1; let mut seen: HashSet = 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; }