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

Augie Fackler raf at durin42.com
Fri Aug 16 17:03:03 EDT 2019


queued, thanks

> On Aug 16, 2019, at 07:28, Yuya Nishihara <yuya at tcha.org> wrote:
> 
> # 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;
>         }
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list