From 88cd83d715dac7ac8abe7e59af9f6c15c5e169cb Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Wed, 3 Jan 2024 11:40:15 +0000 Subject: [PATCH] refactor: simplify removeconstignore verify leftover review comment: https://github.com/CQCL/hugr/pull/757#discussion_r1439399609 --- src/hugr/rewrite/consts.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/hugr/rewrite/consts.rs b/src/hugr/rewrite/consts.rs index 61be178d5..c2b8dfd76 100644 --- a/src/hugr/rewrite/consts.rs +++ b/src/hugr/rewrite/consts.rs @@ -46,11 +46,12 @@ impl Rewrite for RemoveConstIgnore { if (!h.contains_node(node)) || (!h.get_optype(node).is_load_constant()) { return Err(RemoveError::InvalidNode(node)); } - - if h.out_value_types(node) - .next() - .is_some_and(|(p, _)| h.linked_inputs(node, p).next().is_some()) - { + let (p, _) = h + .out_value_types(node) + .exactly_one() + .ok() + .expect("LoadConstant has only one output."); + if h.linked_inputs(node, p).next().is_some() { return Err(RemoveError::ValueUsed(node)); }