2 releases

0.1.1 Apr 12, 2024
0.1.0 Feb 13, 2024

#1044 in Rust patterns

Download history 9/week @ 2024-02-07 59/week @ 2024-02-14 23/week @ 2024-02-21 10/week @ 2024-02-28 5/week @ 2024-03-27 10/week @ 2024-04-03 171/week @ 2024-04-10 5/week @ 2024-04-17

188 downloads per month

MIT license

4KB

Okey - Everything is Result::Ok...

Ideally this crate should not be used used with the macro_rules_attribute crate from Daniel Henry-Mantilla. So make sure to install that too...

cargo add macro_rules_attribute

Usage

#[macro_use]
extern crate macro_rules_attribute;

use okey::okey;

#[apply(okey)]
fn my_name() -> Result<&'static str> {
    return "David";
}

In the example above my_name will automatically return a Result::Ok variant with "David" as it's inner value.

Note that this won't work with "implicit returns", you need to explicitly put the return keyword for this to work.

Returning an error

#[macro_use]
extern crate macro_rules_attribute;

use okey::okey;

#[apply(okey)]
fn my_name() -> Result<&'static str> {
    return Err(some_error());
}

No runtime deps