Skip to content

Commit

Permalink
docs: Tweaks to main example (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
croyzor authored Jan 30, 2024
1 parent 4f9eeb9 commit c4653f5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
//! use hugr::type_row;
//! use hugr::types::FunctionType;
//!
//! // The type of qubits, `QB_T` is in the prelude but, by default, no gateset
//! // is defined. This module provides Hadamard and CX gates.
//! mod mini_quantum_extension {
//! use smol_str::SmolStr;
//!
Expand Down Expand Up @@ -113,18 +115,18 @@
//! // ├───┤┌─┴─┐┌─┐
//! // q_1: ┤ H ├┤ X ├┤M├
//! // └───┘└───┘└╥┘
//! // c:
//! // c:
//! fn make_dfg_hugr() -> Result<Hugr, BuildError> {
//! let mut dfg_builder = DFGBuilder::new(FunctionType::new(
//! type_row![QB_T, QB_T],
//! type_row![QB_T, QB_T, BOOL_T],
//! ))?;
//! let [wire0, wire1] = dfg_builder.input_wires_arr();
//! let wire2 = dfg_builder.add_dataflow_op(h_gate(), vec![wire0])?;
//! let wire3 = dfg_builder.add_dataflow_op(h_gate(), vec![wire1])?;
//! let wire45 = dfg_builder.add_dataflow_op(cx_gate(), wire2.outputs().chain(wire3.outputs()))?;
//! let wire67 = dfg_builder.add_dataflow_op(measure(), wire45.outputs().last())?;
//! dfg_builder.finish_prelude_hugr_with_outputs(wire45.outputs().take(1).chain(wire67.outputs()))
//! let h0 = dfg_builder.add_dataflow_op(h_gate(), vec![wire0])?;
//! let h1 = dfg_builder.add_dataflow_op(h_gate(), vec![wire1])?;
//! let cx = dfg_builder.add_dataflow_op(cx_gate(), h0.outputs().chain(h1.outputs()))?;
//! let measure = dfg_builder.add_dataflow_op(measure(), cx.outputs().last())?;
//! dfg_builder.finish_prelude_hugr_with_outputs(cx.outputs().take(1).chain(measure.outputs()))
//! }
//!
//! let h: Hugr = make_dfg_hugr().unwrap();
Expand Down

0 comments on commit c4653f5

Please sign in to comment.