pub enum ControlFlow {
Normal(ExecResult),
Break {
levels: usize,
result: ExecResult,
},
Continue {
levels: usize,
result: ExecResult,
},
Return {
value: ExecResult,
},
Exit {
code: i64,
},
}Expand description
Control flow signal from statement execution.
Normal execution returns Normal(result). Loop control uses Break and Continue.
Function returns use Return, and script exits use Exit.
Variants§
Normal(ExecResult)
Normal completion with a result.
Break
Break out of loop(s). levels indicates how many loops to break out of.
Continue
Continue to next iteration of loop(s). levels indicates how many loops to skip.
Return
Return from a function with a result.
Fields
value: ExecResultExit
Exit the entire script with an exit code.
Implementations§
Source§impl ControlFlow
impl ControlFlow
Sourcepub fn ok(result: ExecResult) -> Self
pub fn ok(result: ExecResult) -> Self
Create a normal control flow with a successful result.
Sourcepub fn continue_one() -> Self
pub fn continue_one() -> Self
Create a continue with 1 level.
Sourcepub fn continue_n(n: usize) -> Self
pub fn continue_n(n: usize) -> Self
Create a continue with n levels.
Sourcepub fn return_value(value: ExecResult) -> Self
pub fn return_value(value: ExecResult) -> Self
Create a return with a value.
Sourcepub fn into_result(self) -> Option<ExecResult>
pub fn into_result(self) -> Option<ExecResult>
Get the result if this is normal flow.
Sourcepub fn decrement_level(&mut self) -> bool
pub fn decrement_level(&mut self) -> bool
Decrement break/continue levels by 1 and return whether we should stop here.
Returns true if the break/continue should be handled at this level,
false if it should propagate further.
Trait Implementations§
Source§impl Clone for ControlFlow
impl Clone for ControlFlow
Source§fn clone(&self) -> ControlFlow
fn clone(&self) -> ControlFlow
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ControlFlow
impl Debug for ControlFlow
Source§impl Default for ControlFlow
impl Default for ControlFlow
Source§impl From<ExecResult> for ControlFlow
impl From<ExecResult> for ControlFlow
Source§fn from(result: ExecResult) -> Self
fn from(result: ExecResult) -> Self
Auto Trait Implementations§
impl Freeze for ControlFlow
impl RefUnwindSafe for ControlFlow
impl Send for ControlFlow
impl Sync for ControlFlow
impl Unpin for ControlFlow
impl UnwindSafe for ControlFlow
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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