Skip to content

Commit

Permalink
Make ChunkConnection opaque
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Oct 5, 2023
1 parent 77e93f7 commit 395f0d7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/passes/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
//!
//! See [`CircuitChunks`] for more information.
use std::collections::{HashMap, VecDeque};
use std::collections::HashMap;
use std::mem;
use std::ops::{Index, IndexMut};

use derive_more::From;
use hugr::builder::{Container, FunctionBuilder};
use hugr::extension::ExtensionSet;
use hugr::hugr::hugrmut::HugrMut;
Expand Down Expand Up @@ -34,7 +35,8 @@ use tket_json_rs::circuit_json::SerialCircuit;
///
/// When reassembling the circuit, the input/output wires of each chunk are
/// re-linked by matching these identifiers.
pub type ChunkConnection = Wire;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, From)]
pub struct ChunkConnection(Wire);

/// A chunk of a circuit.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -81,13 +83,13 @@ impl Chunk {
.exactly_one()
.ok()
.unwrap();
Wire::new(out_node, out_port)
Wire::new(out_node, out_port).into()
})
.collect();
let outputs = subgraph
.outgoing_ports()
.iter()
.map(|&(node, port)| Wire::new(node, port))
.map(|&(node, port)| Wire::new(node, port).into())
.collect();
Self {
circ: extracted,
Expand Down Expand Up @@ -239,12 +241,12 @@ impl CircuitChunks {
let [circ_input, circ_output] = circ.get_io(circ.root()).unwrap();
let input_connections = circ
.node_outputs(circ_input)
.map(|port| Wire::new(circ_input, port))
.map(|port| Wire::new(circ_input, port).into())
.collect();
let output_connections = circ
.node_inputs(circ_output)
.flat_map(|p| circ.linked_ports(circ_output, p))
.map(|(n, p)| Wire::new(n, p))
.map(|(n, p)| Wire::new(n, p).into())
.collect();

let mut chunks = Vec::new();
Expand Down

0 comments on commit 395f0d7

Please sign in to comment.