[][src]Enum molt::types::ResultCode

pub enum ResultCode {
    Error(Value),
    Return(Value),
    Break,
    Continue,
}

Exceptional results of evaluating a Molt script.

A Molt script can return a normal result, as indicated by the Ok MoltResult, or it can return one of a number of exceptional results, which will bubble up the call stack in the usual way until caught.

  • Error(Value): This code indicates a Molt error; the Value is the error message for display to the user.

  • Return(Value): This code indicates that a Molt procedure called the return command. The Value is the returned value, or the empty value if no value was returned. This result will bubble up until it reaches the top-level of the procedure, which will then return the value as a normal Ok result. If it is received when evaluating an arbitrary script, i.e., if return is called outside of any procedure, the interpreter will convert it into a normal Ok result.

  • Break: This code indicates that the Molt break command was called. It will break out of the inmost enclosing loop in the usual way. When returned outside a loop (or some user-defined control structure that supports break), the interpreter will convert it into an error.

  • Continue: This code indicates that the Molt continue command was called. It will continue with the next iteration of the inmost enclosing loop in the usual way. When returned outside a loop (or some user-defined control structure that supports continue), the interpreter will convert it into an error.

Client code will usually see only the Error code; the others will most often be caught and handled within the interpreter.

Future Work

  • Standard TCL includes more information with non-Ok results, especially for error cases. Ultimately, this type will be need to be extended to support that.

  • Standard TCL allows for an arbitrary number of result codes, which in turn allows the application to define an arbitrary number of new kinds of control structures that are distinct from the standard ones. At some point we might wish to add one or more generic result codes, parallel to Break and Continue, for this purpose.

Variants

Error(Value)
Return(Value)
Break
Continue

Methods

impl ResultCode[src]

pub fn is_error(&self) -> bool[src]

Indicates whether the result code is an Error(String).

Trait Implementations

impl Eq for ResultCode[src]

impl Clone for ResultCode[src]

impl PartialEq<ResultCode> for ResultCode[src]

impl Debug for ResultCode[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]