Skip to content

Commit

Permalink
add 'is_empty' to satisfy clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
BatmanAoD committed Feb 5, 2024
1 parent f568096 commit ae8630e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions quil-rs/src/program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions quil-rs/src/stats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = &Instruction> + '_;
fn get_used_qubits(&self) -> impl IntoIterator<Item = &Qubit>;
}

impl InstructionsSource for Program {
fn is_empty(&self) -> bool {
Program::is_empty(self)
}

fn len(&self) -> usize {
Program::len(self)
}
Expand All @@ -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()
}
Expand Down

0 comments on commit ae8630e

Please sign in to comment.