okey 0.1.1

Everything is Result::Ok...
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 0 items with examples
  • Size
  • Source code size: 4.07 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 118.31 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • david-d-h

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());
}