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 more