Skip to main content

compile

Function compile 

Source
pub fn compile(graph: &BlockGraph, distance: u32) -> Result<Bloq, CompileError>
Expand description

Compile graph at distance, returning the lowered program.

The one-shot for the common case: a fresh private template cache, no artifacts wrapper, and a validated distance (no panic on user input). Reach for CompileContext when several compilations should share compiled templates, and for compile_with when the full CompileArtifacts are wanted.

§Errors

Returns CompileError::InvalidDistance if distance is not odd and in 3..=MAX_CODE_DISTANCE, and any compilation error the graph provokes.

§Examples

use bloq_compile::compile;
use bloq_graph::GalleryItem;

let bloq = compile(&GalleryItem::CNOT.build(), 3)?;
assert!(bloq.quantum_node_count() > 0);