pub struct Program(_);Expand description
A parsed program of Brainfuck-link language.
Each instruction can be acceseed by ProgramIndex.
Implementations
sourceimpl Program
impl Program
sourcepub fn new(instructions: impl Into<Vec<Instruction>>) -> Self
pub fn new(instructions: impl Into<Vec<Instruction>>) -> Self
Create a new program from an Instruction vector.
sourcepub fn instructions(&self) -> &[Instruction]
pub fn instructions(&self) -> &[Instruction]
Get the instructions of the program.
sourcepub fn first_index(&self) -> Option<ProgramIndex>
pub fn first_index(&self) -> Option<ProgramIndex>
Get an indef which points the first instruction of the program.
If instructins are empty, returns None.
sourcepub fn step_index(&self, index: &mut ProgramIndex) -> bool
pub fn step_index(&self, index: &mut ProgramIndex) -> bool
Step index to the next instruction.
If the index already points to the last instruction of the program or
the last instruction of the sub-instructions (in Instruction::UntilZero instruction),
the index is not changed and this function returns false.
Otherwise, the index is changed to point to the next instruction and
this function returns true.
This function does not step into sub-instructions of Instruction::UntilZero instruction.
Trait Implementations
sourceimpl Index<&'_ ProgramIndex> for Program
impl Index<&'_ ProgramIndex> for Program
type Output = Instruction
type Output = Instruction
The returned type after indexing.
sourcefn index(&self, index: &ProgramIndex) -> &Self::Output
fn index(&self, index: &ProgramIndex) -> &Self::Output
Performs the indexing (container[index]) operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnwindSafe for Program
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more