diff --git a/src/hugr.rs b/src/hugr.rs index 34bfa6098..ff0c3788e 100644 --- a/src/hugr.rs +++ b/src/hugr.rs @@ -387,14 +387,6 @@ impl Port { } } - /// Creates a new incoming port. - #[inline] - pub fn new_incoming(port: impl Into) -> Self { - Self { - offset: portgraph::PortOffset::new_incoming(port.into().index()), - } - } - /// Converts to an [IncomingPort] if this port is one; else fails with /// [HugrError::InvalidPortDirection] #[inline] @@ -407,14 +399,6 @@ impl Port { } } - /// Creates a new outgoing port. - #[inline] - pub fn new_outgoing(port: impl Into) -> Self { - Self { - offset: portgraph::PortOffset::new_outgoing(port.into().index()), - } - } - /// Converts to an [OutgoingPort] if this port is one; else fails with /// [HugrError::InvalidPortDirection] #[inline] @@ -492,13 +476,17 @@ impl From for OutgoingPort { impl From for Port { fn from(value: IncomingPort) -> Self { - Port::new_incoming(value) + Self { + offset: portgraph::PortOffset::new_incoming(value.index()), + } } } impl From for Port { fn from(value: OutgoingPort) -> Self { - Port::new_outgoing(value) + Self { + offset: portgraph::PortOffset::new_outgoing(value.index()), + } } } diff --git a/src/hugr/hugrmut.rs b/src/hugr/hugrmut.rs index b7bd8308f..ad4d6f02d 100644 --- a/src/hugr/hugrmut.rs +++ b/src/hugr/hugrmut.rs @@ -259,9 +259,9 @@ impl + AsMut> HugrMut for T { ) -> Result<(), HugrError> { self.as_mut().graph.link_nodes( src.index, - Port::new_outgoing(src_port).index(), + src_port.into().index(), dst.index, - Port::new_incoming(dst_port).index(), + dst_port.into().index(), )?; Ok(()) } diff --git a/src/hugr/serialize.rs b/src/hugr/serialize.rs index 2fdc2fb36..8078e7911 100644 --- a/src/hugr/serialize.rs +++ b/src/hugr/serialize.rs @@ -274,6 +274,7 @@ pub mod test { use super::*; use crate::extension::{EMPTY_REG, PRELUDE_REGISTRY}; use crate::hugr::hugrmut::sealed::HugrMutInternals; + use crate::hugr::OutgoingPort; use crate::{ builder::{ test::closed_dfg_root_hugr, Container, DFGBuilder, Dataflow, DataflowHugr, @@ -283,7 +284,6 @@ pub mod test { hugr::NodeType, ops::{dataflow::IOTrait, Input, LeafOp, Module, Output, DFG}, types::{FunctionType, Type}, - Port, }; use itertools::Itertools; use portgraph::{ @@ -466,7 +466,7 @@ pub mod test { // Now add a new input let new_in = hugr.add_op(Input::new([QB].to_vec())); - hugr.disconnect(old_in, Port::new_outgoing(0)).unwrap(); + hugr.disconnect(old_in, OutgoingPort::from(0)).unwrap(); hugr.connect(new_in, 0, out, 0).unwrap(); hugr.move_before_sibling(new_in, old_in).unwrap(); hugr.remove_node(old_in).unwrap(); diff --git a/src/hugr/validate.rs b/src/hugr/validate.rs index 3338c081a..b21411d2a 100644 --- a/src/hugr/validate.rs +++ b/src/hugr/validate.rs @@ -746,7 +746,7 @@ mod test { Extension, ExtensionId, ExtensionSet, TypeDefBound, EMPTY_REG, PRELUDE_REGISTRY, }; use crate::hugr::hugrmut::sealed::HugrMutInternals; - use crate::hugr::{HugrError, HugrMut, NodeType}; + use crate::hugr::{HugrError, HugrMut, IncomingPort, NodeType}; use crate::macros::const_extension_ids; use crate::ops::dataflow::IOTrait; use crate::ops::{self, LeafOp, OpType}; @@ -1146,7 +1146,7 @@ mod test { h.update_validate(&EMPTY_REG), Err(ValidationError::UnconnectedPort { node: and, - port: Port::new_incoming(1), + port: IncomingPort::from(1).into(), port_kind: EdgeKind::Value(BOOL_T) }) );