4 releases
0.1.3 | Jun 8, 2020 |
---|---|
0.1.2 | Apr 23, 2020 |
0.1.1 | Apr 17, 2020 |
0.1.0 | Apr 16, 2020 |
#1690 in Procedural macros
9KB
183 lines
Irrefutable
Procedural macro to convert a refutable let expression to an irrefutable.
Examples
panic:
#![feature(proc_macro_hygiene)]
use irrefutable::irrefutable;
#[irrefutable(panic("The cause."))]
let Some((a, b)) = Some(("a", "b"));
expands to:
let (a, b) = if let Some((a, b)) = Some(("a", "b")) {
(a, b)
} else {
panic!("The cause.");
};
return:
#![feature(proc_macro_hygiene)]
use irrefutable::irrefutable;
#[irrefutable(return)]
let Some((a, b)) = Some(("a", "b"));
expands to:
let (a, b) = if let Some((a, b)) = Some(("a", "b")) {
(a, b)
} else {
return;
};
unreachable:
#![feature(proc_macro_hygiene)]
use irrefutable::irrefutable;
#[irrefutable(unreachable)]
let Some((a, b)) = Some(("a", "b"));
expands to:
let (a, b) = if let Some((a, b)) = Some(("a", "b")) {
(a, b)
} else {
unreachable!();
};
Dependencies
~1.5MB
~35K SLoC