1 unstable release

Uses old Rust 2015

0.1.0 Dec 3, 2015

#5 in #libstd

WTFPL license

3KB

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.

No runtime deps

Features