Crates.io | yeet-ops |
lib.rs | yeet-ops |
version | 1.0.0 |
source | src |
created_at | 2022-07-08 14:14:40.558875 |
updated_at | 2022-07-08 14:14:40.558875 |
description | An accompanying library for the experimental `do yeet` statement in Rust |
homepage | https://github.com/ewpratten/yeet-ops |
repository | https://github.com/ewpratten/yeet-ops |
max_upload_size | |
id | 621856 |
size | 41,378 |
yeet!
macroyeet-ops
is a super small crate to compliment the do yeet
statement implemented in https://github.com/rust-lang/rust/pull/96376
This crate requires a nightly build of Rust.
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));
}