diff --git a/quil-rs/src/program/mod.rs b/quil-rs/src/program/mod.rs index 07dd2143..a727dadb 100644 --- a/quil-rs/src/program/mod.rs +++ b/quil-rs/src/program/mod.rs @@ -474,6 +474,10 @@ impl Program { Box::new(move |key| qubit_resolutions.get(key).copied()) } + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + pub fn len(&self) -> usize { self.memory_regions.len() + self.frames.len() diff --git a/quil-rs/src/stats/mod.rs b/quil-rs/src/stats/mod.rs index 88113a76..246dfad2 100644 --- a/quil-rs/src/stats/mod.rs +++ b/quil-rs/src/stats/mod.rs @@ -15,12 +15,17 @@ use crate::{ use execution_graph::{Error as ExecutionGraphError, ExecutionGraph}; pub trait InstructionsSource { + fn is_empty(&self) -> bool; fn len(&self) -> usize; fn body_instructions(&self) -> impl Iterator + '_; fn get_used_qubits(&self) -> impl IntoIterator; } impl InstructionsSource for Program { + fn is_empty(&self) -> bool { + Program::is_empty(self) + } + fn len(&self) -> usize { Program::len(self) } @@ -39,6 +44,10 @@ impl InstructionsSource for Program { } impl InstructionsSource for &Program { + fn is_empty(&self) -> bool { + (*self).is_empty() + } + fn len(&self) -> usize { (*self).len() }