pub struct BasicBlock<'p> { /* private fields */ }
Implementations§
Source§impl<'p> BasicBlock<'p>
impl<'p> BasicBlock<'p>
pub fn label(&self) -> Option<&'p Target>
pub fn instruction_index_offset(&self) -> usize
pub fn instructions(&self) -> &[&'p Instruction]
pub fn terminator(&self) -> &BasicBlockTerminator<'p>
Sourcepub fn as_schedule_seconds(
&self,
program: &Program,
) -> Result<Schedule<Seconds>, BasicBlockScheduleError>
pub fn as_schedule_seconds( &self, program: &Program, ) -> Result<Schedule<Seconds>, BasicBlockScheduleError>
Compute the flattened schedule for this BasicBlock
in terms of seconds,
using a default built-in calculation for the duration of scheduled instructions.
§Arguments
program
- The program containing this basic block. This is used to retrieve frame and calibration information.
Sourcepub fn as_schedule<F, Time>(
&self,
program: &'p Program,
get_duration: F,
) -> Result<Schedule<Time>, BasicBlockScheduleError>where
F: Fn(&Program, &Instruction) -> Option<Time>,
Time: Clone + Debug + PartialOrd + Add<Time, Output = Time> + Sub<Time, Output = Time> + Zero,
pub fn as_schedule<F, Time>(
&self,
program: &'p Program,
get_duration: F,
) -> Result<Schedule<Time>, BasicBlockScheduleError>where
F: Fn(&Program, &Instruction) -> Option<Time>,
Time: Clone + Debug + PartialOrd + Add<Time, Output = Time> + Sub<Time, Output = Time> + Zero,
Compute the schedule for this BasicBlock
in terms of a generic unit of time,
using a provided function to calculate the duration of scheduled instructions in that unit.
§Arguments
program
- The program containing this basic block. This is used to retrieve frame and calibration information.get_duration
- A function that takes a program and an instruction and returns the duration of the instruction in the desired time unit, orNone
if the instruction’s duration is not known.
Note: when an instruction is expanded, the “time” of that original instruction includes the times of all of the resulting instructions. This may cause gate times to be longer than a user might expect.
To understand why, consider a program like this:
# One-qubit frame
DEFFRAME 0 "a":
ATTRIBUTE: 1
# Two-qubit frame
DEFFRAME 0 1 "b":
ATTRIBUTE: 1
DEFCAL A 0:
PULSE 0 "a" flat(duration: 1.0)
DEFCAL B 0 1:
FENCE 1
PULSE 0 1 "b" flat(duration: 1.0)
A 0
B 0 1
B 0
will be scheduled from time 0 to time 2, because its inner FENCE
is scheduled for time 0.
This may be unexpected if the user expects to see only the timing of the inner PULSE
.
Trait Implementations§
Source§impl<'p> Clone for BasicBlock<'p>
impl<'p> Clone for BasicBlock<'p>
Source§fn clone(&self) -> BasicBlock<'p>
fn clone(&self) -> BasicBlock<'p>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'p> Debug for BasicBlock<'p>
impl<'p> Debug for BasicBlock<'p>
Source§impl<'p> Default for BasicBlock<'p>
impl<'p> Default for BasicBlock<'p>
Source§fn default() -> BasicBlock<'p>
fn default() -> BasicBlock<'p>
Returns the “default value” for a type. Read more
Source§impl<'b> From<&'b BasicBlockOwned> for BasicBlock<'b>
impl<'b> From<&'b BasicBlockOwned> for BasicBlock<'b>
Source§fn from(value: &'b BasicBlockOwned) -> Self
fn from(value: &'b BasicBlockOwned) -> Self
Converts to this type from the input type.
Source§impl From<BasicBlock<'_>> for BasicBlockOwned
impl From<BasicBlock<'_>> for BasicBlockOwned
Source§fn from(value: BasicBlock<'_>) -> Self
fn from(value: BasicBlock<'_>) -> Self
Converts to this type from the input type.
Source§impl<'a> TryFrom<&BasicBlock<'a>> for QubitGraph<'a>
impl<'a> TryFrom<&BasicBlock<'a>> for QubitGraph<'a>
Source§type Error = QubitGraphError
type Error = QubitGraphError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl<'p> Freeze for BasicBlock<'p>
impl<'p> RefUnwindSafe for BasicBlock<'p>
impl<'p> Send for BasicBlock<'p>
impl<'p> Sync for BasicBlock<'p>
impl<'p> Unpin for BasicBlock<'p>
impl<'p> UnwindSafe for BasicBlock<'p>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.