#syntax

ordoo

Macro to allow early exit of control flow in Options and Results

2 releases

0.1.1 Sep 27, 2023
0.1.0 Sep 27, 2023

#1555 in Development tools

MIT license

4KB

docs.rs

This crate simply adds a macro that makes the syntax simpler to end control flow.

The macro or_do will allow you to return a function early if a value is None or Err.

use ordoo::or_do;

let val: i32 = or_do!(Some(1), return);

let val: i32 = or_do!(Ok::<_, std::io::Error>(1), _ => return);

I may add more QoL macros/functions later.


lib.rs:

This crate simply adds a macro that makes the syntax simpler to end control flow.

The macro [or_do] will allow you to return a function early if a value is None or Err.

use ordoo::or_do;

let val: i32 = or_do!(Some(1), return);

let val: i32 = or_do!(Ok::<_, std::io::Error>(1), _ => return);

I may add more QoL macros/functions later.

No runtime deps