| Crates.io | q-rust |
| lib.rs | q-rust |
| version | 0.1.1 |
| created_at | 2025-11-04 06:23:56.367392+00 |
| updated_at | 2025-11-23 04:12:04.917172+00 |
| description | A modular quantum transpiler and QASM 2.0 parser written in Rust. |
| homepage | |
| repository | https://github.com/Arturacu/Q-Rust |
| max_upload_size | |
| id | 1915837 |
| size | 41,217 |
A quantum transpiler written in Rust, designed to parse, analyze, and optimize quantum circuits.
petgraph).Q-Rust enforces strict OpenQASM 2.0 compliance. It will explicitly reject:
OPENQASM 3.0; will trigger an Unsupported OpenQASM version error.OPENQASM 2.0; header.Circuit::validate() method warns if a circuit has no measurements, as it will not produce output on real hardware.Add to your Cargo.toml:
[dependencies]
q-rust = "0.1"
use q_rust::parser::parse_qasm;
fn main() {
let qasm_code = r#"
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q[1] -> c[1];
"#;
match parse_qasm(qasm_code) {
Ok(circuit) => {
println!("Successfully parsed circuit with {} operations.", circuit.operations.len());
println!("Qubits: {}, Classical Bits: {}", circuit.num_qubits, circuit.num_cbits);
}
Err(e) => eprintln!("Error parsing QASM: {}", e),
}
}
use q_rust::backend::Backend;
fn main() {
let mut backend = Backend::new("MyQuantumMachine".to_string(), 5);
// Define connectivity (0 -> 1 -> 2)
backend.set_coupling_map(vec![(0, 1), (1, 2)]);
println!("Backend {} has {} qubits.", backend.name, backend.num_qubits);
}
This project adheres to the OpenQASM 2.0 specification:
MIT or Apache-2.0