RustQIP
Quantum Computing library leveraging graph building to build efficient quantum circuit simulations.
See all the examples in the examples directory of the Github repository.
Example (CSWAP)
Here's an example of a small circuit where two groups of qubits are swapped conditioned on a third. This circuit is very small, only three operations plus a measurement, so the boilerplate can look quite large in compairison, but that setup provides the ability to construct circuits easily and safely when they do get larger.
use *;
// Setup inputs
let mut b = new;
let q = b.qubit;
let ra = b.register?;
let rb = b.register?;
// We will want to feed in some inputs later.
let ha = ra.handle;
let hb = rb.handle;
// Define circuit
let q = b.hadamard;
let = condition?;
let q = b.hadamard;
let = b.measure;
// Print circuit diagram
run_debug?;
// Run circuit
let = ?;
println!;