Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.31 KB

README.md

File metadata and controls

42 lines (31 loc) · 1.31 KB

The yeet! macro

Crates.io Docs.rs Build Clippy Audit

yeet-ops is a super small crate to compliment the do yeet statement implemented in rust-lang/rust#96376

This crate requires a nightly build of Rust.

Usage

Simply toss this in your Cargo.toml dependencies:

yeet-ops = "^1.0.0"

Then you are good to go!

#![feature(yeet_expr)] // Needed!
use yeet_ops::yeet;

/// A function that yeets `None`
fn test() -> Option<i32> {
    yeet!();
}

/// A function that yeets `Err(1)`
fn test2() -> Result<String, i32> {
    yeet!(1);
}

fn main() {
    // Did it yeet?
    assert_eq!(test(), None);
    assert_eq!(test2(), Err(1));
}