#let #macro #return #value #case #extract #deprecated

deprecated let_or_return

Convenient macro to extract a value via if let, and return in the else case

4 releases (stable)

1.0.2 Oct 1, 2023
1.0.1 Sep 18, 2023
0.1.0 May 12, 2023

#33 in #let

32 downloads per month

MIT license

6KB

let_or_return

maintenance-status Crates.io docs.rs CI Crates.io

⚠️ This crate is deprecated. Use the let-else statement instead.

Convenient Rust macro to extract a value via if let, and return in the else case.

See doc.rs documentation


lib.rs:

⚠️ This crate is deprecated. Use the let-else statement instead.

The let-else statement is exactly doing what I intended to do with let_or_return macro:

fn process_x(opt_x: &Option<u32>) -> bool {
    let Some(x) = opt_x else { return false };
    // use x
    true
}

Original documentation

Convenient macro to extract a value via if let, and return in the else case.

No runtime deps