@@ -126,16 +126,16 @@ impl<HostNode: HugrNode> SimpleReplacement<HostNode> {
126126 /// of `self`.
127127 ///
128128 /// The returned port will be in `replacement`, unless the wire in the
129- /// replacement is empty and `return_invalid ` is
130- /// [`BoundaryMode::SnapToHost`] (the default), in which case it
131- /// will be another `host` port. If [`BoundaryMode::IncludeIO`] is
132- /// passed, the returned port will always be in `replacement` even if it
133- /// is invalid (i.e. it is an IO node in the replacement).
129+ /// replacement is empty and `boundary ` is [`BoundaryMode::SnapToHost`] (the
130+ /// default), in which case it will be another `host` port. If
131+ /// [`BoundaryMode::IncludeIO`] is passed, the returned port will always
132+ /// be in `replacement` even if it is invalid (i.e. it is an IO node in
133+ /// the replacement).
134134 pub fn linked_replacement_output (
135135 & self ,
136136 port : impl Into < HostPort < HostNode , IncomingPort > > ,
137137 host : & impl HugrView < Node = HostNode > ,
138- return_invalid : BoundaryMode ,
138+ boundary : BoundaryMode ,
139139 ) -> Option < BoundaryPort < HostNode , OutgoingPort > > {
140140 let HostPort ( node, port) = port. into ( ) ;
141141 let pos = self
@@ -144,7 +144,7 @@ impl<HostNode: HugrNode> SimpleReplacement<HostNode> {
144144 . iter ( )
145145 . position ( move |& ( n, p) | host. linked_inputs ( n, p) . contains ( & ( node, port) ) ) ?;
146146
147- Some ( self . linked_replacement_output_by_position ( pos, host, return_invalid ) )
147+ Some ( self . linked_replacement_output_by_position ( pos, host, boundary ) )
148148 }
149149
150150 /// The outgoing port linked to the i-th output boundary edge of `subgraph`.
@@ -155,7 +155,7 @@ impl<HostNode: HugrNode> SimpleReplacement<HostNode> {
155155 & self ,
156156 pos : usize ,
157157 host : & impl HugrView < Node = HostNode > ,
158- return_invalid : BoundaryMode ,
158+ boundary : BoundaryMode ,
159159 ) -> BoundaryPort < HostNode , OutgoingPort > {
160160 debug_assert ! ( pos < self . subgraph( ) . signature( host) . output_count( ) ) ;
161161
@@ -166,7 +166,7 @@ impl<HostNode: HugrNode> SimpleReplacement<HostNode> {
166166 . single_linked_output ( repl_out, pos)
167167 . expect ( "valid dfg wire" ) ;
168168
169- if out_node != repl_inp || return_invalid == BoundaryMode :: IncludeIO {
169+ if out_node != repl_inp || boundary == BoundaryMode :: IncludeIO {
170170 BoundaryPort :: Replacement ( out_node, out_port)
171171 } else {
172172 let ( in_node, in_port) = * self . subgraph . incoming_ports ( ) [ out_port. index ( ) ]
@@ -213,17 +213,16 @@ impl<HostNode: HugrNode> SimpleReplacement<HostNode> {
213213 /// of `self`.
214214 ///
215215 /// The returned ports will be in `replacement`, unless the wires in the
216- /// replacement are empty and `return_invalid` is
217- /// [`BoundaryMode::SnapToHost`] (the default), in which case they
218- /// will be other `host` ports. If [`BoundaryMode::IncludeIO`] is
219- /// passed, the returned ports will always be in
220- /// `replacement` even if they are invalid (i.e. they are an IO node in
221- /// the replacement).
216+ /// replacement are empty and `boundary` is [`BoundaryMode::SnapToHost`]
217+ /// (the default), in which case they will be other `host` ports. If
218+ /// [`BoundaryMode::IncludeIO`] is passed, the returned ports will
219+ /// always be in `replacement` even if they are invalid (i.e. they are
220+ /// an IO node in the replacement).
222221 pub fn linked_replacement_inputs < ' a > (
223222 & ' a self ,
224223 port : impl Into < HostPort < HostNode , OutgoingPort > > ,
225224 host : & ' a impl HugrView < Node = HostNode > ,
226- return_invalid : BoundaryMode ,
225+ boundary : BoundaryMode ,
227226 ) -> impl Iterator < Item = BoundaryPort < HostNode , IncomingPort > > + ' a {
228227 let HostPort ( node, port) = port. into ( ) ;
229228 let positions = self
@@ -235,25 +234,24 @@ impl<HostNode: HugrNode> SimpleReplacement<HostNode> {
235234 host. single_linked_output ( n, p) . expect ( "valid dfg wire" ) == ( node, port)
236235 } ) ;
237236
238- positions. flat_map ( move |pos| {
239- self . linked_replacement_inputs_by_position ( pos, host, return_invalid)
240- } )
237+ positions
238+ . flat_map ( move |pos| self . linked_replacement_inputs_by_position ( pos, host, boundary) )
241239 }
242240
243241 /// The incoming ports linked to the i-th input boundary edge of `subgraph`.
244242 fn linked_replacement_inputs_by_position (
245243 & self ,
246244 pos : usize ,
247245 host : & impl HugrView < Node = HostNode > ,
248- return_invalid : BoundaryMode ,
246+ boundary : BoundaryMode ,
249247 ) -> impl Iterator < Item = BoundaryPort < HostNode , IncomingPort > > {
250248 debug_assert ! ( pos < self . subgraph( ) . signature( host) . input_count( ) ) ;
251249
252250 let [ repl_inp, repl_out] = self . get_replacement_io ( ) ;
253251 self . replacement
254252 . linked_inputs ( repl_inp, pos)
255253 . flat_map ( move |( in_node, in_port) | {
256- if in_node != repl_out || return_invalid == BoundaryMode :: IncludeIO {
254+ if in_node != repl_out || boundary == BoundaryMode :: IncludeIO {
257255 Either :: Left ( std:: iter:: once ( BoundaryPort :: Replacement ( in_node, in_port) ) )
258256 } else {
259257 let ( out_node, out_port) = self . subgraph . outgoing_ports ( ) [ in_port. index ( ) ] ;
@@ -552,8 +550,8 @@ impl<HostNode: HugrNode> PatchVerification for SimpleReplacement<HostNode> {
552550 }
553551}
554552
555- /// In [`SimpleReplacement`], some nodes in the replacement may not be valid
556- /// after the replacement is applied.
553+ /// In [`SimpleReplacement::replacement `], IO nodes marking the boundary will
554+ /// not be valid nodes in the host after the replacement is applied.
557555///
558556/// This enum allows specifying whether these invalid nodes on the boundary
559557/// should be returned or should be resolved to valid nodes in the host.
0 commit comments