soma 0.1.0

Simplify `Option` usage
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented0 out of 0 items with examples
  • Size
  • Source code size: 3.44 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Documentation
  • hauleth/soma
    5 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hauleth

Soma

Simple macro to simplify Option handling in Rust.

This is my answer to RFC 1303 issue.

Installation

Like other Crates you should use cargo-edit and then:

cargo add soma

Usage

This is equivalent to try! macro from libstd:

#[macro_use]
extern crate soma;

//
let foo: Option<usize> = //
let bar: usize = try_some!(foo); // This will return with `None` if `foo` is
                                 // `None`
// equivalent to:
//
// let bar: usize = match foo {
//     Some(val) => val,
//     None => return None,
// }

let baz: usize - try_some!(foo => return); // This will break execution if `foo`
                                           // is `None`
// equivalent to
//
// let baz: usize = match foo {
//     Some(val) => val,
//     None => return,
// }

License

Check out LICENSE file.