[][src]Macro molt::molt_ok

macro_rules! molt_ok {
    () => { ... };
    ($arg:expr) => { ... };
    ($($arg:tt)*) => { ... };
}

Returns an Ok MoltResult.

If called with no arguments, returns an empty value as the Ok result. If called with one argument, returns the argument as the Ok result, converting it to a value automatically. If called with two or more arguments, computes the Ok result using format!(); the first argument is naturally the format string.

Examples

use molt::*;

// Return the empty result
fn func1() -> MoltResult {
    // ...
    molt_ok!()
}

assert_eq!(func1(), Ok(Value::empty()));

// Return an arbitrary value
fn func2() -> MoltResult {
    // ...
    molt_ok!(17)
}

assert_eq!(func2(), Ok(17.into()));

// Return a formatted value
fn func3() -> MoltResult {
    // ...
    molt_ok!("The answer is {}", 17)
}

assert_eq!(func3(), Ok("The answer is 17".into()));