From cf69e016b55fb2fecbd89367c780023ce3f91d94 Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Wed, 3 Jan 2024 14:24:18 +0000 Subject: [PATCH] refactor: simplify removeconstignore verify (#768) 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 6ac32a65a..2fee7a53d 100644 --- a/src/hugr/rewrite/consts.rs +++ b/src/hugr/rewrite/consts.rs @@ -45,11 +45,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)); }