From d1625e085e9618c2f91a77514a182b7a0ef37bc5 Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Tue, 3 Dec 2024 15:49:23 +0000 Subject: [PATCH] refactor: replace.rs: use HugrView::first_child (missed from #1721) --- hugr-core/src/hugr/rewrite/replace.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hugr-core/src/hugr/rewrite/replace.rs b/hugr-core/src/hugr/rewrite/replace.rs index 3ccb4db80..5d770af4b 100644 --- a/hugr-core/src/hugr/rewrite/replace.rs +++ b/hugr-core/src/hugr/rewrite/replace.rs @@ -314,11 +314,7 @@ impl Rewrite for Replacement { for (new_parent, &old_parent) in self.adoptions.iter() { let new_parent = node_map.get(new_parent).unwrap(); debug_assert!(h.children(old_parent).next().is_some()); - loop { - let ch = match h.children(old_parent).next() { - None => break, - Some(c) => c, - }; + while let Some(ch) = h.first_child(old_parent) { h.set_parent(ch, *new_parent); } }