pub struct Repeat { /* private fields */ }
Expand description
A stack of repeat counters.
Implementations§
Source§impl Repeat
impl Repeat
Sourcepub fn repeat_from(&mut self, location: usize, amount: Word) -> RepeatResult<()>
pub fn repeat_from(&mut self, location: usize, amount: Word) -> RepeatResult<()>
Add a new repeat location and counter to the stack. Counts down to 0.
Sourcepub fn repeat_to(&mut self, location: usize, limit: Word) -> RepeatResult<()>
pub fn repeat_to(&mut self, location: usize, limit: Word) -> RepeatResult<()>
Add a new repeat location and counter to the stack. Counts up from 0 to limit - 1.
Sourcepub fn counter(&self) -> RepeatResult<Word>
pub fn counter(&self) -> RepeatResult<Word>
Get the current repeat counter.
Returns an error if the stack is empty.
Sourcepub fn repeat(&mut self) -> RepeatResult<Option<usize>>
pub fn repeat(&mut self) -> RepeatResult<Option<usize>>
If there is a counter on the stack and the counter has greater then 1 repeat left then this will decrement the counter and return the index to repeat to.
If the counter is 1 then this will pop the counter and return None because the repeat is done.
If called when the stack is empty then this will return an error.
Note that because the code has run once before the
RepeatEnd
is hit then we stop at 1.
Trait Implementations§
impl StructuralPartialEq for Repeat
Auto Trait Implementations§
impl Freeze for Repeat
impl RefUnwindSafe for Repeat
impl Send for Repeat
impl Sync for Repeat
impl Unpin for Repeat
impl UnwindSafe for Repeat
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more